xou/elixlsx

Office For Mac, reports error and discards styles when opening file

Closed this issue · 2 comments

Thanks for the great project!

This can be reproduced by creating the simplest possible file then trying to open it in Microsoft Excel for Mac (https://products.office.com/en-ca/buy/compare-microsoft-office-products?tab=tabs-2).

For example if you run the example from the readme:

Workbook.append_sheet(%Workbook{}, Sheet.with_name("Sheet 1") |> Sheet.set_cell("A1", "Hello", bold: true)) |> Elixlsx.write_to("hello.xlsx")

Then open the resulting file with Office for Mac results in the following warning:

image

If you click "Open and Repair" the file will open but be displayed with no styling and a prompt as follows:
image

If you click "View" to see the log you'll see:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>Repair Result to hello1050.xml</logFileName><summary>Errors were detected in file '/Users/bruce/Work/viewprogis/viewprogis_web/vpg/hello105.xlsx'</summary><removedParts summary="Following is a list of removed parts:"><removedPart>Removed Part: /xl/styles.xml with XML error.  (Styles) Load error. Line 36, column 36.</removedPart></removedParts><repairedRecords summary="Following is a list of repairs:"><repairedRecord>Repaired Records: Cell information from /xl/worksheets/sheet1.xml</repairedRecord><repairedRecord>Repaired Records: Cell information from /xl/worksheets/sheet2.xml</repairedRecord></repairedRecords></recoveryLog>

Suggesting a problem with xl/styles.xml

I think I have found a solution and will submit a pull request soon.

Thanks again, please check out #18 which resolves the issue.

xou commented

Awesome, thank you for your help!!