mini-software / MiniExcel

Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet (support Linux, Mac)
https://www.nuget.org/packages/MiniExcel/
Apache License 2.0
2.79k stars 337 forks source link

Readonly file (not released properly) and issue with formulas in xl/calcChain.xml #489

Open jsgervais opened 1 year ago

jsgervais commented 1 year ago

Excel Type

Upload Excel File

mini_TotalEnVigueur (1).xlsx

Please attach your issue file by dragging or droppng, selecting or pasting them.

warning readonly

image

warning for an issue in calcChain.xml

image

calcChain.xml content from templatate and before excel auto fix

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<calcChain xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><c r="M6" i="1" l="1"/><c r="L6" i="1"/><c r="K6" i="1"/><c r="J6" i="1"/><c r="N6" i="1"/></calcChain>

calcChain.xml content after fixing by excel

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<calcChain xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><c r="N393" i="1" l="1"/><c r="M393" i="1"/><c r="L393" i="1"/><c r="K393" i="1"/><c r="J393" i="1"/></calcChain>

MiniExcel Version

current, 1.30.3

Description

Excel Line 6 contain formulas that are pushed down by an IEnumerable field one line 5, but isn't updated in xl/calcChain.xml

Excel file not released properly, when opening it's in read only mode because being 'edited' by another user. Generated excel file still in read-only (no released properly). MniExcel not disposed properly?

jsgervais commented 1 year ago

I think formulas in excel templates sheets needs to be indexed in calcChain.xml.

here's the formulas in my generated template (388 rows added)

image
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<calcChain xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><c r="M393" i="1" l="1"/><c r="K393" i="1"/><c r="J393" i="1"/><c r="N393" i="1"/><c r="L393" i="1"/></calcChain>

calcChain looks like an index of all the formulas cell, row, sheed index -- i.e. <c r="J393" i="1"/>

jsgervais commented 1 year ago

the calchain requires parsing _rels/workbook.xml.rels to get worksheet indexes rid#

calcChain.xml content looks like this

image

r = columrow, i = sheet index