Fix XLSX Writer on Windows plaftorms

A bug was introduced, preventing Spout to create valid XLSX files on Windows.
This commits reverts the changes that introduced DIRECTORY_SEPARATOR everywhere
and fixes the original issue with the writer by normalizing paths when creating
the zipped file.
This commit is contained in:
Adrien Loison committed 2015-07-01 15:24:58 -07:00
1 parent c6ebf115fc
commit b3df57d2e5
9 files changed
+29 -38

No files matched your search

@@ -162,12 +162,11 @@ class SharedStringsHelper
}
/**
* @return string The path to the shared strings XML file, working cross-platforms
* @return string The path to the shared strings XML file
*/
protected function getSharedStringsFilePath()
{
$sharedStringsXmlFilePath = str_replace('/', DIRECTORY_SEPARATOR, self::SHARED_STRINGS_XML_FILE_PATH);
return 'zip://' . $this->filePath . '#' . $sharedStringsXmlFilePath;
return 'zip://' . $this->filePath . '#' . self::SHARED_STRINGS_XML_FILE_PATH;
}
/**
@@ -250,7 +249,7 @@ class SharedStringsHelper
protected function getSharedStringTempFilePath($sharedStringIndex)
{
$numTempFile = intval($sharedStringIndex / self::MAX_NUM_STRINGS_PER_TEMP_FILE);
return $this->tempFolder . DIRECTORY_SEPARATOR . 'sharedstrings' . $numTempFile;
return $this->tempFolder . '/sharedstrings' . $numTempFile;
}
/**
@@ -186,8 +186,7 @@ class WorksheetHelper
*/
protected function getFileAsXMLElementWithNamespace($xmlFilePath, $mainNamespace)
{
$normalizedXmlFilePath = str_replace('/', DIRECTORY_SEPARATOR, $xmlFilePath);
$xmlContents = $this->globalFunctionsHelper->file_get_contents('zip://' . $this->filePath . '#' . $normalizedXmlFilePath);
$xmlContents = $this->globalFunctionsHelper->file_get_contents('zip://' . $this->filePath . '#' . $xmlFilePath);
$xmlElement = new \SimpleXMLElement($xmlContents);
$xmlElement->registerXPathNamespace('ns', $mainNamespace);
+2 -3
View File
@@ -33,12 +33,11 @@ class Worksheet
/**
* @return string Path of the XML file containing the worksheet data,
* without the leading slash and working cross-platforms.
* without the leading slash.
*/
public function getDataXmlFilePath()
{
$dataXmlFilePath = ltrim($this->dataXmlFilePath, '/');
return str_replace('/', DIRECTORY_SEPARATOR, $dataXmlFilePath);
return ltrim($this->dataXmlFilePath, '/');
}
/**