Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

WAMP and Spout 2.8 XMLReader::open Issue #125

Closed
danddavi opened this issue Oct 13, 2015 · 14 comments
Closed

WAMP and Spout 2.8 XMLReader::open Issue #125

danddavi opened this issue Oct 13, 2015 · 14 comments

Comments

@danddavi
Copy link

I installed spout using composer.

Still having error on windows.
Warning: XMLReader::open(zip://xlsx_files/one_sheet_with_inline_strings.xlsx#xl/sharedStrings.xml): failed to open stream: operation failed in C:\wamp\www\excel_reader_test\vendor\box\spout\src\Spout\Reader\Wrapper\XMLReader.php on line 37

I have tried the suggested fix.
str_replace('/', DIRECTORY_SEPARATOR, $this->filePath)

Still same error except for the path
zip://xlsx_files\one_sheet_with_inline_strings.xlsx#xl/sharedStrings.xml

So I thought of changing the slash on the xml path
$str_xml = str_replace('/', DIRECTORY_SEPARATOR, self::SHARED_STRINGS_XML_FILE_PATH);
return 'zip://' . str_replace('/', DIRECTORY_SEPARATOR, $this->filePath) . '#' . self::SHARED_STRINGS_XML_FILE_PATH;

Same error. So I tried changing the slash in the constant.
const SHARED_STRINGS_XML_FILE_PATH = 'xl/sharedStrings.xml';

I got this error
Warning: file_get_contents(zip://xlsx_files\one_sheet_with_inline_strings.xlsx#[Content_Types].xml): failed to open stream: operation failed in C:\wamp\www\excel_reader_test\vendor\box\spout\src\Spout\Common\Helper\GlobalFunctionsHelper.php on line 167

Here is my setup.
Win 7
Apache 2.4.9
PHP 5.5.12
spout 2.3

PHP Info
libxml 2.9.1
zip 1.11.0
Libzip 0.10.1
zLib 1.2.7.3

Any Help would be greatly appreciated.

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

Hey @danddavi, is it working with other files? Like "one_sheet_with_shared_strings.xlsx"?

@danddavi
Copy link
Author

I put everything back to original config and tried running "one_sheet_with_shared_strings.xlsx"
Then tried it by doing the same steps as I mentioned above each one with the same results.
I also tried making a simple xlsx file to see if that would run with no success.

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

https://gist.github.com/adrilo/a50b83814d119cf7a7fc
Can you try running this code and let me know if it displays "note - SUCCESS"?

@danddavi
Copy link
Author

Sure can you send me the link to download the "test.zip" file you want to test against.

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

It is automatically created by the script

@danddavi
Copy link
Author

Oops I should really read the whole code..
It's a FAIL!!

Warning: XMLReader::open(zip://test.zip#test.xml): failed to open stream: operation failed in C:\wamp\www\excel_reader_test\test.php on line 12

I am guessing its something on my end. Any ideas on what it can be?

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

I updated the test code: https://gist.github.com/adrilo/a50b83814d119cf7a7fc
Can you please re-run it?

@danddavi
Copy link
Author

Here is the errors. Everything failed.

Warning: fopen(zip://test.zip#test.xml): failed to open stream: operation failed in C:\wamp\www\excel_reader_test\test.php on line 18

Warning: file_get_contents(zip://test.zip#test.xml): failed to open stream: operation failed in C:\wamp\www\excel_reader_test\test.php on line 29

Warning: XMLReader::open(zip://test.zip#test.xml): failed to open stream: operation failed in C:\wamp\www\excel_reader_test\test.php on line 40

@danddavi
Copy link
Author

Just FYI
I know that the ZipArchive works. I have used it for basic open() and extractTo() methods before but I have never used the zip://

Your help is greatly appreciated..

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

Updated the Gist again. I added a test to check if the "zip" stream wrapper is registered.
Can you try it?

@danddavi
Copy link
Author

WooHoo
fopen: SUCCESS ( Tove Jani Reminder Don't forget me this weekend! ) file_get_contents: SUCCESS ( Tove Jani Reminder Don't forget me this weekend! ) XMLReader: SUCCESS (note)

So I see you used realpath() is that what needs to be done to all filepaths used by zip://

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

Yep, I guess Windows does not like relative paths...
I created #126 to fix the issue. As I can't repro it on my machine, would you mind test the change and let me know if it actually fixes your problem?

@danddavi
Copy link
Author

I used realpath($this->filePath) where 'zip://' was being used and that fixed the issue.

SheetIterator.php
SharedStringsHelper.php
SheetHelper.php
RowIterator.php

Thanks for the great support!!!!

@adrilo
Copy link
Collaborator

adrilo commented Oct 14, 2015

No problem! Thanks for filing this issue :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants