php-excel-writer
php-excel-writer copied to clipboard
Error on opening Excel file with cell types other than text
Hi! It's a great library, thank you!
I have an error when I'm generating cells different than text. I'm parsing my custom types to ones accepted by excel-writer:
function getTypeByName($type){
switch ($type) {
case 'pricePLN':
return '#,##0.00 [$ZŁ];[RED]-#,##0.00 [$ZŁ]';
case 'price':
return 'money';
case 'number':
return 'float';
case 'date':
return 'DD.MM.YYYY';
case 'monthYear':
return 'MM.YYYY';
case 'text':
default:
return 'text';
}
}
That's Excel error:
Translation:
Excel program opened a file by repairing or deleting unreadable content.
Records fixed: Information about cells from part /xl/worksheets/sheet1.xml
Here is generated Excel file, may be helpful for you:
test.xlsx
Environment:
- PHP 7.2
- Windows 10
- php-excel-writer 0.1.7
By the way, can I make zł
in currency lowercase? When I'm writting '#,##0.00 [$zł];[RED]-#,##0.00 [$zł]'
result is 20,00 Zł which looks weird, 20,00 zł is ok.
About second thing I see that in ExcelWritter class inside addCellFormat function is strtoupper
, that's why my currency is wrong.
$cellFormat = strtoupper($this->getCellFormat($cellFormat));
Is it really required?
About first thing, when I remove strings from penultimate line there is no error. So I need to change data type for that cells only, can I do it? If yes, how?
@ptyskju hi, thanks, I check on the description