0

I am using PHPExcel to read a large "xls" file. Firstly, I am determining the file type for reader using PHPExcel_IOFactory::identify($inputFileName). However, PHPExcel is wrongly identifying it as HTML file and using HTML Reader which fails with DOM errors.

After some searching, I found that PHPExcel does not work well with stream wrappers. Refer here.

I have no idea what stream wrappers are, and the file I am trying to read is downloaded using wget.

Please let me know how to remove the stream wrappers, so that PHPExcel can identify the file correctly.

Thank you.

Chandru
  • 1,306
  • 13
  • 21
AJINKYA
  • 741
  • 2
  • 9
  • 20
  • Be careful with the excel filename : PHPExcel does not like special characters like accentued ones. – OlivierH Oct 11 '16 at 10:38

1 Answers1

0

Download the file to a local drive on your server, even if just as a temporary file, then try to identify/read it.... but PHPExcel uses fseek() for most of its Readers, which isn't supported by many of the stream wrappers.

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • File is on local drive but still it fails. – AJINKYA Jan 03 '15 at 08:54
  • In that case, take a close look at the file in a text editor and see what it actually contains.... PHPExcel will only tell you it's `HTML` if it contains markup – Mark Baker Jan 03 '15 at 08:55
  • Its a simple xls file, opens in MS Excel, no HTML markup at all. – AJINKYA Jan 03 '15 at 08:56
  • I said open in a text editor.... MS Excel is quite capable of opening HTML files, even if they have an extension of .xls; but PHPExcel will not arbitrarily tell you that a file is `HTML` if it doesn't contain markup, as a worst case it might tell you that it's `CSV`, but not `HTML` – Mark Baker Jan 03 '15 at 08:59
  • 2
    Also, can you provide a link to the file that's being misinterpreted.... if I'm going to spend several hours trying to track down and fix a potential bug in PHPExcel, I want something to actual demonstrate that bug so that I can test and see if any changes I make fix it – Mark Baker Jan 03 '15 at 09:02
  • I checked, it contains the data in html table format, how do I parse it in PHPExcel and get final CSV. – AJINKYA Jan 03 '15 at 13:03
  • You use the HTML Reader that PHPExcel recommends via identify() to load the file, then the CSV Writer to save as a csv file – Mark Baker Jan 03 '15 at 14:50
  • Already tried but it to fails load the file, any other suggestion? – AJINKYA Jan 04 '15 at 04:02