Laravel-excel: Loses all styling when exporting with a font size?

Created on 17 Feb 2017  路  3Comments  路  Source: Maatwebsite/Laravel-Excel

Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].

Package version, Laravel version

Package: 2.1
Laravel: 5.3

Expected behaviour

Export an xlsx file with a larger font size for one cell

Actual behaviour

Lose all styling

Steps to reproduce the behaviour

<table>
    <tbody>
        <tr>
            <td colspan="5" style="text-align: center; font-size: 18px; background: #000000; color: #76933C; font-weight: bold;">Test</td>
        </tr>
    </tbody>
</table>

If I remove the font-size: 18px I get a file with the rest of the styling on that cell, if I add the font-size: 18px I get an error when opening the excel file that says:

"We found a problem with some content in 'example.xlsx'. Do you want us to try to recover as much as we can?"

Clicking yes opens it, but with no styling.

This is in Microsoft Office Plus 2016

Most helpful comment

You can fix it by not giving it a unit like this

<table>
    <tbody>
        <tr>
            <td colspan="5" style="text-align: center; font-size: 18; background: #000000; color: #76933C; font-weight: bold;">Test</td>
        </tr>
    </tbody>
</table>

reference: https://github.com/PHPOffice/PHPExcel/issues/1201

All 3 comments

I'm unable to reproduce this.

You can fix it by not giving it a unit like this

<table>
    <tbody>
        <tr>
            <td colspan="5" style="text-align: center; font-size: 18; background: #000000; color: #76933C; font-weight: bold;">Test</td>
        </tr>
    </tbody>
</table>

reference: https://github.com/PHPOffice/PHPExcel/issues/1201

Same for, me. The problem is, that it is not working with px. Not only inline styles, but also external css file. Work around, which provided by mrclronald is working only for Excel file, but not for UI, also, if it would work, I don't want to use inline style in all places I need.
if I write in external css: td {width:200px} - columns became 0 px wide in excel file and 200px wide in ui. Otherwise if I use style like this: td { width:200 } - columns become very wide in excel and auto in UI

Additional if you use "px" in your style, excel file opens with recovery and error message:
Removed Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 2, column 0.
Repaired Records: Cell information from /xl/worksheets/sheet1.xml part

PHP version: 7.1.13
Laravel version: 5.6.15
Package version: 2.1.27

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ellej16 picture ellej16  路  3Comments

bahmanyaghoobi picture bahmanyaghoobi  路  3Comments

kurianic picture kurianic  路  3Comments

alejandri picture alejandri  路  3Comments

vandolphreyes picture vandolphreyes  路  3Comments