Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

barlevd
Copy link
Contributor

@barlevd barlevd commented Apr 30, 2024

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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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
```
@barlevd barlevd changed the base branch from master to v2 April 30, 2024 13:33
@barlevd barlevd changed the base branch from v2 to master April 30, 2024 13:34
@xuri xuri added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 30, 2024
Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you follow the pull request template, explain why is this change required and what problem does it solve?

@xuri xuri linked an issue Apr 30, 2024 that may be closed by this pull request
@xuri xuri added this to Improve the Compatibility in v2.9.0 Apr 30, 2024
Saving workbook with reverse sorted internal part path to keep same hash of identical files
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           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 Coverage Δ
unittests 99.21% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your pull request. I have made some changes based on your code.

@xuri xuri merged commit 781c384 into qax-os:master Apr 30, 2024
34 checks passed
@xuri xuri added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 30, 2024
barlevd added a commit to barlevd/excelize that referenced this pull request Apr 30, 2024
@barlevd barlevd deleted the bugfix-sortZipStreams branch April 30, 2024 16:36
@xuri xuri changed the title Update file.go Saving workbook with reverse sorted internal part path to keep same hash of identical files May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
Status: Improve the Compatibility
v2.9.0
Improve the Compatibility
Development

Successfully merging this pull request may close these issues.

File is missing media type
2 participants