php-excel-writer icon indicating copy to clipboard operation
php-excel-writer copied to clipboard

Error on opening Excel file with cell types other than text

Open ptyskju opened this issue 5 years ago • 3 comments

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:
image 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 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.

ptyskju avatar Jul 19 '19 08:07 ptyskju

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?

ptyskju avatar Jul 19 '19 09:07 ptyskju

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 avatar Jul 22 '19 11:07 ptyskju

@ptyskju hi, thanks, I check on the description

ellumilel avatar Jul 25 '19 09:07 ellumilel