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

Diff error when comparing excel with openpyxl edited excel #10

Open
Leonas2000 opened this issue Sep 3, 2024 · 1 comment
Open

Diff error when comparing excel with openpyxl edited excel #10

Leonas2000 opened this issue Sep 3, 2024 · 1 comment

Comments

@Leonas2000
Copy link

I noticed when editing with openpyxl some sub files are lost. The whole customXml folder is deleted. Which then gives the following error.

opc diff input.xlsx output.xlsx
Traceback (most recent call last):
File "/usr/local/bin/opc", line 8, in
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.12/site-packages/opcdiag/cli.py", line 309, in main
command_controller.execute(argv)
File "/usr/local/lib/python3.12/site-packages/opcdiag/cli.py", line 54, in execute
command.execute(args, self._app_controller)
File "/usr/local/lib/python3.12/site-packages/opcdiag/cli.py", line 147, in execute
app_controller.diff_pkg(args.pkg_1_path, args.pkg_2_path)
File "/usr/local/lib/python3.12/site-packages/opcdiag/controller.py", line 58, in diff_pkg
rels_diffs = DiffPresenter.rels_diffs(package_1, package_2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opcdiag/presenter.py", line 120, in rels_diffs
return DiffPresenter._pkg_item_diffs(package_1_rels_items, package_2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opcdiag/presenter.py", line 155, in _pkg_item_diffs
pkg_item_2 = package_2.find_item_by_uri_tail(uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opcdiag/model.py", line 47, in find_item_by_uri_tail
raise KeyError("No item with name '%s'" % uri_tail)
KeyError: "No item with name 'customXml/_rels/item1.xml.rels'"

@scanny
Copy link
Contributor

scanny commented Sep 13, 2024

Can you provide a pair of files that reproduces this behavior?

Offhand it looks like opc-diag is not sophisticated enough to handle diffs between items where whole package parts (zip-archive "files") have been deleted.

Maybe you could open and save the file with openpyxl without making changes as a first step, which might drop the customXml part then make changes to the worksheet and use opcdiag on those latter two versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants