Data is coming corrupt after 4000 records

Topics: Developer Forum, User Forum
Apr 30, 2009 at 5:49 AM
Hi,

I am facing strange problem. The date in some rows is coming corrupt after 4000 records in the Excel 5 format. The filed in which data is coming corrupt is date field.

Also once data comes corrupt in date field for 5 to 6 records all date fields upto end comes empty . Also name field which is in japanese also come empty in many records. Can this be a problem of large number of records (7041 in my case) or Japanese text problem.

I have earlier used Spreadsheet_excel_writer class for creating excel but in that I was getting error in SST problems after 200 records for which I have shifted to PHP_Excel class.

Any help will be appreciated.
Developer
Apr 30, 2009 at 9:37 AM
Edited Apr 30, 2009 at 9:37 AM
Can you send me the corrupt xls file so I can inspect? (erik at phpexcel dot net).

Developer
Apr 30, 2009 at 5:10 PM
I'm investigating this. Can you help by testing if your script is working with PHPExcel 1.6.5 ? Some changes were made after this release that could affect this.

Developer
Apr 30, 2009 at 8:33 PM
After inspecting the file it looks like this is result of invalid UTF-8 input.

PHPExcel does not sanitize UTF-8 input which it probably should. Work item created for this:
http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=9902

If this is urgent you can use quick trick for sanitization:

$string = 'some string that may be corrupt';
$string = mb_convert_encoding($string, 'UTF-8', 'UTF-8'); // sanitize
$cell->setValue($string);

May 4, 2009 at 9:17 AM
mb_convert_encoding method works like a charm.

Thanks a lot.