Invalid cell coordinate AAAA20

Topics: Developer Forum
Apr 5, 2011 at 7:58 PM

I get this error when trying to load one my xls files:

 

Fatal error: Uncaught exception 'Exception' with message 'Invalid cell coordinate AAAA20

 

Im using this code:

 

<?php
echo date('H:i:s') . " Write to CSV format\n";
//$objPHPExcel = new PHPExcel();

$objPHPExcel = PHPExcel_IOFactory::load("xls/xls1.xls");
$objPHPExcel->setActiveSheetIndex(0); 

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')
    ->setDelimiter('|')
    ->setEnclosure('')
    ->setLineEnding("\r\n")
    ->setSheetIndex(0)
    ->save('xls/write.csv');
?>


this only happens with one file, but ofcourse its the file I need. I have to retreive this with a little fgets to fetch it from a remote server everyday,
 then I need to convert it to CSV to place in a DB.

I have tried sample files and they work as expected.

Apr 6, 2011 at 3:35 PM

just FYI. I can open it in Excel and any excel viewer without issue.

Coordinator
Apr 7, 2011 at 9:25 PM

Is this really an Excel BIFF file, or simply a file with a .xls extension?

 

Can you try either:

echo PHPExcel_IOFactory::identify("xls/xls1.xls");

to see which reader PHPExcel is using to try and read this file;

 

or open the file in a normal text editor to see what it looks like.

Apr 7, 2011 at 9:55 PM

I figured out last night that the file was actually an HTML file with an xls extension. I got my hands on a smaller "xls" file and got it to work with PHPExcel but it had html markup in my CSV file..

So I did a little reasearch on the forum here and found out that my file might be a fake.. and what do ya know? it sure was.. Thanks for your reply, I was able to import it into open office and export it the records I needed.

From now on, I have a HTML 2 CSV converter using php since I only need daily records on cron from the xls in the future. PHPExcel SURELY helps with some other data I fetch on crons that does use real XLS files.

Coordinator
Apr 7, 2011 at 10:17 PM

I've done some initial work on an HTML Reader for PHPExcel, because "fake" xls files like this are quite a common occurrence... and typically the content is either CSV or HTML.

PHPExcel can already detect a csv file using the PHPExcel_IOFactory::load() and PHPExcel_IOFactory::identify() methods, but it can't recognise HTML, and then will simply default to assuming the file is a CSV.

Unfortunately, the HTML Reader is still very "experimental", and has real problems with rich text elements, <br /> tags, and badly nested elements. I've been using PHP's DOM parser, and while this is generally very forgiving with badly formed markup, but seems to be creating some of the problems in this case. My current thinking is to scrap what I've done so far, and start again from scratch using some of the methods from within the PDF writer library that parse both HTML and style. In theory, if I can get that working, I can also provide an HTML to Rich Text Run convertor, which is an oft-requested feature in PHPExcel.