qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
17.62k stars 1.68k forks source link

Saving workbook with reverse sorted internal part path to keep same hash of identical files #1890

Closed barlevd closed 2 months ago

barlevd commented 2 months ago

Update zip sort order

Original order

[Content_Types].xml
_rels/.rels
docProps/app.xml
docProps/core.xml
xl/_rels/workbook.xml.rels
xl/sharedStrings.xml
xl/styles.xml
xl/theme/theme1.xml
xl/workbook.xml
xl/worksheets/sheet2.xml
xl/worksheets/sheet3.xml
xl/worksheets/sheet4.xml
xl/worksheets/sheet5.xml
xl/worksheets/sheet6.xml
xl/worksheets/sheet7.xml
xl/worksheets/sheet8.xml
xl/worksheets/sheet9.xml

New order

xl/_rels/workbook.xml.rels
xl/pivotCache/pivotCacheDefinition1.xml
xl/pivotTables/_rels/pivotTable1.xml.rels
xl/pivotTables/pivotTable1.xml
xl/sharedStrings.xml
xl/styles.xml
xl/theme/theme1.xml
xl/workbook.xml
xl/worksheets/_rels/sheet8.xml.rels
xl/worksheets/sheet1.xml
xl/worksheets/sheet12.xml
xl/worksheets/sheet2.xml
xl/worksheets/sheet3.xml
xl/worksheets/sheet4.xml
xl/worksheets/sheet5.xml
xl/worksheets/sheet6.xml
xl/worksheets/sheet7.xml
xl/worksheets/sheet8.xml
[Content_Types].xml
_rels/.rels
docProps/app.xml
docProps/core.xml

PR Details

Description

This change sorts the inter zip streams so that the Excel file passes validation as a Microsoft Excel 2007+

Related Issue

Motivation and Context

How Has This Been Tested

This change was tested and verified that the resulting output includes the Microsoft Excel 2007+ metadata to show up properly using file tool, and mmmagic.

Run on Mac OS. Upload of the file to a server now shows it is a proper xlsx file.

This change doesn't affect other areas of the code.

Types of changes

Checklist

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.21%. Comparing base (7715c14) to head (8deaf25).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1890 +/- ## ======================================= Coverage 99.21% 99.21% ======================================= Files 32 32 Lines 24085 24085 ======================================= Hits 23895 23895 Misses 102 102 Partials 88 88 ``` | [Flag](https://app.codecov.io/gh/qax-os/excelize/pull/1890/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qax-os) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/qax-os/excelize/pull/1890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qax-os) | `99.21% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qax-os#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.