Skip to content

Issue with OpenXml WmlComparer when comparing documents with different numbering styles, Bug with Open XML SDK #1634

New issue

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

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

Already on GitHub? # to your account

Closed
yatintripathi opened this issue Dec 26, 2023 · 13 comments

Comments

@yatintripathi
Copy link

yatintripathi commented Dec 26, 2023

Describe the bug
I'm currently using the OpenXml library in C# to compare two Word documents utilizing the WmlComparer.Compare method. The comparison works well in most cases, but I'm encountering an issue specifically related to legal style numbering.

When comparing two documents, if one contains legal style numbering and the other doesn't, the resulting compared document loses the legal numbering entirely, without even maintaining a strikethrough format.

I've already implemented the comparison using WmlComparer.Compare and set the necessary comparison settings. However, I'm struggling to retain the legal style numbering or apply strikethrough formatting to the mismatched numbering when generating the compared document.

For more Reference :- [(https://stackoverflow.com/questions/77697178/issue-with-openxml-wmlcomparer-when-comparing-documents-with-different-numbering?noredirect=1#comment136981416_77697178)]

Screenshots
These are how the documents look :-
Screenshot (55)
Screenshot (57)

Microsoft Word's inherent working functionality :-
Screenshot (58)

OpenXML SDK WmlComparer working functionality :-
Screenshot (60)

Yo will see differences between Microsoft Word's inherent working functionality and OpenXML SDK WmlComparer working functionality.

To Reproduce
Create two docs in similar manner as in the screenshots of how the documents look and compare it via WmlComparer code you will be able to reproduce the Observed behavior and to reproduce the Expected behavior compare the two docs via compare functionality that word provides.

Steps to Reproduce the behavior:

  1. Go to WORD.
  2. Click on Review Tab and click on compare and compare two word documents , one with Legal Numbering System and one without it and compare.
  3. You will see inherent working functionality of compare
  4. To generate Legal numbering in a word document
  5. Click on Multilevel list on the taskbar of word
  6. Click on Define new multilevel list
  7. Click on more
  8. On the right hand side you will see a check box of Legal Numbering Style
  9. Check it and press OK.

Observed behavior
As you can see from the screenshot above "OpenXML SDK WmlComparer working functionality" legal numbering is not retained.

Expected behavior
As you can see from the screenshot above "Microsoft Word's inherent working functionality" legal numbering is retained.

Desktop (please complete the following information):

  • OS: Windows
  • Office version : Version 2311 (Build 17029.20108)
  • .NET Target: .NET Core Version 7.0.102
  • DocumentFormat.OpenXml Version: 2.20.0
  • OpenXMLPowerTools Version : 4.5.3.2

Below is the code :-

WmlComparerSettings settings = new WmlComparerSettings
            {
                AuthorForRevisions = author,
                DetailThreshold = 0
            };
            var originalDoc = new WmlDocument(originalPath.ToString());
            var revisedDoc = new WmlDocument(revisedPath.ToString());

            WmlDocument comparedDoc = WmlComparer.Compare(originalDoc, revisedDoc, settings);

@EricWhiteDev
@ThomasBarnekow
@twsouthwick
@tomjebo @mikeebowen @hunyu @AlfredHellstern @lindexi

@lindexi
Copy link
Member

lindexi commented Dec 28, 2023

@yatintripathi It seems that WmlComparer does not belong to the feature of this repo.

Should you bring this issues to https://github.com/OpenXmlDev/Open-Xml-PowerTools ?

@yatintripathi
Copy link
Author

yatintripathi commented Dec 28, 2023

@lindexi I tried, but there is no "Issues" tab open in that repository.

@yatintripathi
Copy link
Author

@ThomasBarnekow
Copy link
Collaborator

@yatintripathi, the only one able to help with this is @EricWhiteDev. He is the author of the WmlComparer, which is unfortunately very complex. Should he not be able to deal with this soon enough, you will unfortunately have to look into this yourself.

@yatintripathi
Copy link
Author

@EricWhiteDev Could you please help me with this?

@JSv4
Copy link

JSv4 commented Jan 5, 2024

@yatintripathi, would love to hear if you've found a solution to this one. Please report back!

@yatintripathi
Copy link
Author

@yatintripathi, would love to hear if you've found a solution to this one. Please report back!

@JSv4 no i didn't find any solutions yet.

@twsouthwick
Copy link
Member

Since this is not a part of the SDK, I'm going to close it.

@ThomasBarnekow @EricWhiteDev you two are listed as owners on the OpenXmlDev org - is there a place this issue can be moved to be tracked near where WmlComparer is?

@ThomasBarnekow
Copy link
Collaborator

@twsouthwick, it seems @EricWhiteDev turned off issues for the Open-Xml-PowerTools repository. He is unfortunately the only one who can help with the WmlComparer, which is a very complex piece of software. The OP would have to contact Eric directly if he wants to ask for help. On the other hand, this is open source software, so the OP can at least try to fix this himself.

@JSv4
Copy link

JSv4 commented Jan 15, 2024

@yatintripathi, this is a problem (docx redlining) I've been wrestling with myself for a while now. Your post got me motivated thinking there are others trying to solve the issue too. I started a little project called python_redlines to create a wrapper for WmlComparer and have some thoughts on how to use pure python in v2. Would definitely welcome thoughts and contributions.

@yatintri
Copy link

@JSv4 , thrilled to hear about your project! I'll take a look at the code and familiarize myself with the project. Looking forward to being a part of this initiative!

@DandelionWenjing
Copy link

@yatintripathi Also have issues here, do you have any better solution for now? Thanks!

@yatintri
Copy link

yatintri commented Oct 1, 2024

@yatintripathi Also have issues here, do you have any better solution for now? Thanks!

@DandelionWenjing I solved this by using INTEROP instead of OPENXML. But the deployment process of INTEROP is a bit complex, but it will not have any issues which OPENXML has.

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

No branches or pull requests

7 participants