Excel styles are getting corrupted when processed using closedxml in C#

Neeraj Chappayil 0 Reputation points
2024-03-14T07:42:11.44+00:00

Hi All,

 

I have an excel workbook with 14 worksheets. It have lots of tables and data. When I manipulate the excel using the closedxml the styles of the excel is getting corrupted. manipulation means hiding, inserting data etc. Even if the excel is just opened using closedxml and closed then also the excel styles are corrupting. When I open the excel it is prompting me to repair the excel with the below error message. Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.

Repaired Records: Table Style from /xl/styles.xml part (Styles)

Please ask if any more information needed This is very important for us. Please give any solution, idea and suggestion.

Microsoft 365 and Office Development Other
Microsoft 365 and Office Excel For business Windows
Developer technologies C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sherif Khalaf 95 Reputation points
    2024-03-19T13:30:28.58+00:00
    • Update ClosedXML: Make sure you're using the latest version of ClosedXML. Bugs related to style handling might have been fixed in newer releases. Check the official website for updates: https://www.nuget.org/packages/ClosedXML/
    • Isolate the Issue: Try creating a minimal reproducible example. Create a new C# project with a simple workbook containing a few tables and data. Manipulate the workbook using ClosedXML and see if the styles get corrupted. This will help isolate if the issue is specific to your complex workbook or a general problem with your code.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.