From 39c72a91b4104a09e6e2cd461979182d0a0d72f9 Mon Sep 17 00:00:00 2001 From: Adrien Loison Date: Fri, 3 Apr 2015 21:00:00 -0700 Subject: [PATCH] Fix DIRECTORY_SEPARATOR bug occurring on Windows Fixes #3: The sheetN.xml files location is dynamically retrieved when parsing [Content_Types].xml. In this file, the location is like "/xl/worksheets/sheet1.xml". Because the zip stream wrapper expects the zip entry name to be like "xl/worksheets/sheet1/xml" (without the first "/"), this first "/" needs to be trimmed. It was trimmed using: ltrim($this->dataXmlFilePath, DIRECTORY_SEPARATOR); which obvisously does not work on Windows platform where DIRECTORY_SEPARATOR is "\". Replacing DIRECTORY_SEPARATOR by '/' solves this issue. --- src/Spout/Reader/Internal/XLSX/Worksheet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spout/Reader/Internal/XLSX/Worksheet.php b/src/Spout/Reader/Internal/XLSX/Worksheet.php index 6a12357..552c53e 100644 --- a/src/Spout/Reader/Internal/XLSX/Worksheet.php +++ b/src/Spout/Reader/Internal/XLSX/Worksheet.php @@ -31,7 +31,7 @@ class Worksheet */ public function getDataXmlFilePath() { - return ltrim($this->dataXmlFilePath, DIRECTORY_SEPARATOR); + return ltrim($this->dataXmlFilePath, '/'); } /**