You can't add macros but you can open a template file with the macros already there, add your data, and then save.
↧
New Post: Inject macros
↧
Created Unassigned: Excel workbook corrupt after saving [9429]
I have an xlsx workbook that is used as a template. Through a ridiculous amount of coding, I have built a library using OpenXML that _almost_ preserves all formatting of the original file after updating the cells with data. Saddened by the reams of code to accomplish this, I turned to ClosedXML and got quite far with a fraction of the code, and was very happy...until I encountered the attached spreadsheet and executed the following code.
```
var workbook = new XLWorkbook(filePath);
workbook.Save();
```
When I opened the file in Excel, I encountered the prompt to recover the contents of the workbook, since Excel found unreadable content. I clicked Yes. Excel flickered a little, and then I am presented with the alert:
> "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt."
The only hint I have found so far is that the conditional formatting elements in Sheet1.xml are different after saving through ClosedXML than before.
```
var workbook = new XLWorkbook(filePath);
workbook.Save();
```
When I opened the file in Excel, I encountered the prompt to recover the contents of the workbook, since Excel found unreadable content. I clicked Yes. Excel flickered a little, and then I am presented with the alert:
> "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt."
The only hint I have found so far is that the conditional formatting elements in Sheet1.xml are different after saving through ClosedXML than before.
↧
↧
New Post: Error in implicit conversion. Cannot convert null object.
Line 26: // XLWorkbook workbook = new XLWorkbook(@"C:\VK\SampleSite\EXCELChnage\EXCELChnage\GCP_01 Report Output Apr 2.xlsx");
Line 27: // ExcelBeforeFormat(path, 3);
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Error in implicit conversion. Cannot convert null object.
Line 27: // ExcelBeforeFormat(path, 3);
Line 28: XLWorkbook workbook = new XLWorkbook(path); -- Inthe line getting errorError in implicit conversion. Cannot convert null object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Error in implicit conversion. Cannot convert null object.
↧
Commented Unassigned: While Writing to Excel file its throwing an error "'.', hexadecimal value 0x00, is an invalid character." [9421]
Hi All,
While Writing to Excel File using the ClosedXML facing an issue. Above is the error mentioned into caption which I am getting.
Have attached the Excel File which I am trying to Write by passing the DataSet.
Please Reply ASAP.
Thanks,
Samir.
Comments: This also affects us - can reproduce this with the following: ``` byte[] data; using (var stream = new MemoryStream()) { var wb = new XLWorkbook(); wb.AddWorksheet("Sheet1").FirstCell().SetValue("\u0018"); wb.SaveAs(stream); data = stream.ToArray(); } using (var stream = new MemoryStream(data)) { var wb = new XLWorkbook(stream); Assert.AreEqual("\u0018", wb.Worksheets.First().FirstCell().Value); } ``` The above fails on the call to wb.SaveAs, however even if saved correctly the cell value ends up being read as "_x0018_" and the assert will fail. The [ECMA-376 Specification (part 1)](http://www.ecma-international.org/publications/standards/Ecma-376.htm) says the following under the bstr element > Unicode characters that cannot be directly represented in XML as defined by the XML 1.0 specification, shall be escaped using the Unicode numerical character representation escape character format _xHHHH_, where H represents a hexadecimal character in the character's value. [Example: The Unicode character 8 is not permitted in an XML 1.0 document, so it shall be escaped as _x0008_. end example] To store the literal form of an escape sequence, the initial underscore shall itself be escaped (i.e. stored as _x005F_). [Example: The string literal _x0008_ would be stored as _x005F_x0008_. end example] I had a look at how to fix this with the intention of preparing a pull request, but I'm not familiar enough with OpenXml to identify where this encoding method should be applied - at the minimum it needs to be applied to the shared strings, but it looks like this might also apply to other strings too.
While Writing to Excel File using the ClosedXML facing an issue. Above is the error mentioned into caption which I am getting.
Have attached the Excel File which I am trying to Write by passing the DataSet.
Please Reply ASAP.
Thanks,
Samir.
Comments: This also affects us - can reproduce this with the following: ``` byte[] data; using (var stream = new MemoryStream()) { var wb = new XLWorkbook(); wb.AddWorksheet("Sheet1").FirstCell().SetValue("\u0018"); wb.SaveAs(stream); data = stream.ToArray(); } using (var stream = new MemoryStream(data)) { var wb = new XLWorkbook(stream); Assert.AreEqual("\u0018", wb.Worksheets.First().FirstCell().Value); } ``` The above fails on the call to wb.SaveAs, however even if saved correctly the cell value ends up being read as "_x0018_" and the assert will fail. The [ECMA-376 Specification (part 1)](http://www.ecma-international.org/publications/standards/Ecma-376.htm) says the following under the bstr element > Unicode characters that cannot be directly represented in XML as defined by the XML 1.0 specification, shall be escaped using the Unicode numerical character representation escape character format _xHHHH_, where H represents a hexadecimal character in the character's value. [Example: The Unicode character 8 is not permitted in an XML 1.0 document, so it shall be escaped as _x0008_. end example] To store the literal form of an escape sequence, the initial underscore shall itself be escaped (i.e. stored as _x005F_). [Example: The string literal _x0008_ would be stored as _x005F_x0008_. end example] I had a look at how to fix this with the intention of preparing a pull request, but I'm not familiar enough with OpenXml to identify where this encoding method should be applied - at the minimum it needs to be applied to the shared strings, but it looks like this might also apply to other strings too.
↧
New Comment on "Turning off events"
I've had a similar experience to S1 - the business had been complaining about the speed to generate certain excel files (They have over 2 million rows, it going to be slow.) . Turning off events brought things to a reasonable speed, and in the same meeting where they were celebrating that, they introduced new functionality that requires the events...
↧
↧
New Post: Unexpected data conversion
I found that some pattern of text is converted unexpectedly.
Why this happens ?
This is sample code.
But when I created new workbook manually by Excel2013 and typed "06S00055" into "A1" cell, nothing happened.
"06S00055" is a serial number used in my company.
I tried other cases, and found the followings.
Why this happens ?
This is sample code.
var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("New sheet");
ws.Cell(1, 1).Value = "06S00055";
The "A1" cell shows "1980/6/1" in a result.But when I created new workbook manually by Excel2013 and typed "06S00055" into "A1" cell, nothing happened.
"06S00055" is a serial number used in my company.
I tried other cases, and found the followings.
- xxS000yy is converted to date
- xx = month
- yy = year (1925 + yy)
-
day = 1
↧
New Post: Error in implicit conversion. Cannot convert null object.
I get the same error when opening a excel file, any help please???
XLWorkbook workbook = new XLWorkbook(@"C:\code\atr.xlsx");
XLWorkbook workbook = new XLWorkbook(@"C:\code\atr.xlsx");
↧
New Post: Ability to add an IgnoredError?
Is there any way in ClosedXML to bypass cell errors, such as numbers stored as text?
In OpenXML, it's accomplished as follows:
In OpenXML, it's accomplished as follows:
var ignoredError = new IgnoredError
{
SequenceOfReferences =
new ListValue<StringValue>
{
InnerText = "A1:Z20"
},
NumberStoredAsText = true
};
...
sheet.Elements<IgnoredErrors>().Append(ignoredError);
↧
Created Unassigned: Cannot use with .Net 4 [9430]
Hi, I've been trying to use ClosedXML with .NET4, I've installed the proper installation (tried a few versions),
downloaded the DocumentFormat.OpenXml.dll file for 4 (And for 3.5), and also tried using the SDK dll (SDK 2.5) that's in my Program Files dir, and nothing helps.
It compiles ok, but in runtime I get:
{System.IO.FileLoadException: Could not load file or assembly 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
=== Pre-bind state information ===
LOG: DisplayName = ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
(Fully-specified)
LOG: Appbase = file:///C:/views/ResultsManager/
LOG: Initial PrivatePath = NULL
Calling assembly : ResultsManager, Version=1.0.0.3, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
LOG: Attempting download of new URL file:///C:/views/ResultsManager/ClosedXML.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
}
I tried all the options with the properties of both DLLs - "Copy local" (true of false), "Specific Version" (true or false and what not.
Nothing helps.
I've even tried using .NET3.5 ClosedXML with OpenXml v2, and even mix the openXML and closedXML versions (.NET4 with SDK2, .NET3.5 with SDK 2.5, etc')
Any ideas?
Thanks
downloaded the DocumentFormat.OpenXml.dll file for 4 (And for 3.5), and also tried using the SDK dll (SDK 2.5) that's in my Program Files dir, and nothing helps.
It compiles ok, but in runtime I get:
{System.IO.FileLoadException: Could not load file or assembly 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
=== Pre-bind state information ===
LOG: DisplayName = ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
(Fully-specified)
LOG: Appbase = file:///C:/views/ResultsManager/
LOG: Initial PrivatePath = NULL
Calling assembly : ResultsManager, Version=1.0.0.3, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
LOG: Attempting download of new URL file:///C:/views/ResultsManager/ClosedXML.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
}
I tried all the options with the properties of both DLLs - "Copy local" (true of false), "Specific Version" (true or false and what not.
Nothing helps.
I've even tried using .NET3.5 ClosedXML with OpenXml v2, and even mix the openXML and closedXML versions (.NET4 with SDK2, .NET3.5 with SDK 2.5, etc')
Any ideas?
Thanks
↧
↧
New Post: Getting conditional formatting from an existing cell
Is it possible to get the conditional formatting for an existing cell. I can see that you can add it with AddConditionalFormatting method, but cannot see a way to pull it if it already exists. In my scenario I am trying to use a cell as a template for other cells.
Thanks.
Thanks.
↧
Commented Unassigned: Cannot use with .Net 4 [9430]
Hi, I've been trying to use ClosedXML with .NET4, I've installed the proper installation (tried a few versions),
downloaded the DocumentFormat.OpenXml.dll file for 4 (And for 3.5), and also tried using the SDK dll (SDK 2.5) that's in my Program Files dir, and nothing helps.
It compiles ok, but in runtime I get:
{System.IO.FileLoadException: Could not load file or assembly 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
=== Pre-bind state information ===
LOG: DisplayName = ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
(Fully-specified)
LOG: Appbase = file:///C:/views/ResultsManager/
LOG: Initial PrivatePath = NULL
Calling assembly : ResultsManager, Version=1.0.0.3, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
LOG: Attempting download of new URL file:///C:/views/ResultsManager/ClosedXML.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
}
I tried all the options with the properties of both DLLs - "Copy local" (true of false), "Specific Version" (true or false and what not.
Nothing helps.
I've even tried using .NET3.5 ClosedXML with OpenXml v2, and even mix the openXML and closedXML versions (.NET4 with SDK2, .NET3.5 with SDK 2.5, etc')
Any ideas?
Thanks
Comments: There is a Nuget Package available for 3.5 and for 4.0 https://www.nuget.org/packages/ClosedXML Try this one.
downloaded the DocumentFormat.OpenXml.dll file for 4 (And for 3.5), and also tried using the SDK dll (SDK 2.5) that's in my Program Files dir, and nothing helps.
It compiles ok, but in runtime I get:
{System.IO.FileLoadException: Could not load file or assembly 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
=== Pre-bind state information ===
LOG: DisplayName = ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
(Fully-specified)
LOG: Appbase = file:///C:/views/ResultsManager/
LOG: Initial PrivatePath = NULL
Calling assembly : ResultsManager, Version=1.0.0.3, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b
LOG: Attempting download of new URL file:///C:/views/ResultsManager/ClosedXML.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
}
I tried all the options with the properties of both DLLs - "Copy local" (true of false), "Specific Version" (true or false and what not.
Nothing helps.
I've even tried using .NET3.5 ClosedXML with OpenXml v2, and even mix the openXML and closedXML versions (.NET4 with SDK2, .NET3.5 with SDK 2.5, etc')
Any ideas?
Thanks
Comments: There is a Nuget Package available for 3.5 and for 4.0 https://www.nuget.org/packages/ClosedXML Try this one.
↧
New Post: Getting conditional formatting from an existing cell
I haven't done this myself. However, since conditional formatting is stored at the sheet level, try the IXLWorksheet.ConditionalFormats read-only property. Each IXLConditionalFormat in that IEnumerable<IXLConditionalFormat> will have properties that show you which cells participate in the conditional formatting. You should be able to determin if your current cell is one of those.
I hope this helps.
I hope this helps.
↧
New Post: Getting conditional formatting from an existing cell
That does seem to work for getting the existing conditional formatting, thank you. Unfortunately once I retrieve it, there does not seem to be a way to assign it to a new cell. Am I missing something obvious. I tried adding the range of the new cell to the custom format but that did not seem to work.
↧
↧
New Post: Getting conditional formatting from an existing cell
I have dealt with a similar issue before. Maybe this helps you with your problem.
I had to increase the range of all conditional formats on a sheet.
I had to increase the range of all conditional formats on a sheet.
IXLConditionalFormats condFormats = worksheet.ConditionalFormats;
foreach (var format in condFormats)
{
format.Range = worksheet.Range(format.Range.RangeAddress.FirstAddress, newCell.Address);
worksheet.ConditionalFormats.Add(format);
}
↧
Created Unassigned: Inserting the MEDIAN and QUARTILE functions [9431]
Inserting more statistical functions.
↧
Commented Unassigned: Inserting the MEDIAN and QUARTILE functions [9431]
Inserting more statistical functions.
Comments: I have implemented the functions in this way: In Statistical.cs ``` //=morraf= static object Percentile(List<Expression> p) { var range = p[0] as IEnumerable; // the k parameter of the percentile var k = (double)p[1].Evaluate(); // populate the tally object var tally = new Tally(); foreach (var value in range) { System.Diagnostics.Debug.Print(value.ToString()); tally.AddValue(value); } // evaluate return tally.Percentile(k); } //=morraf= static object Quartile(List<Expression> p) { // convert the quartile to percentile var k = (double)p[1].Evaluate() / 4; p[1] = new Expression(k); //p.Add(new Expression(k)); return Percentile(p); } //=morraf= static object Median(List<Expression> p) { // it is percentile 0.5 p.Add(new Expression(0.5)); return Percentile(p); } ``` where tally.Percentile ``` //http://stackoverflow.com/questions/8137391/percentile-calculation public double Percentile(double excelPercentile) { var values = Numerics().ToArray(); Array.Sort(values); double ret = 0; int arrayCount = values.Count(); if (arrayCount > 0) { double n = (arrayCount - 1) * excelPercentile + 1; // Another method: double n = (N + 1) * excelPercentile; if (n == 1d) return values[0]; else if (n == arrayCount) return values[arrayCount - 1]; else { int k = (int)n; double d = n - k; ret = values[k - 1] + d * (values[k] - values[k - 1]); } } return ret; } ```
Comments: I have implemented the functions in this way: In Statistical.cs ``` //=morraf= static object Percentile(List<Expression> p) { var range = p[0] as IEnumerable; // the k parameter of the percentile var k = (double)p[1].Evaluate(); // populate the tally object var tally = new Tally(); foreach (var value in range) { System.Diagnostics.Debug.Print(value.ToString()); tally.AddValue(value); } // evaluate return tally.Percentile(k); } //=morraf= static object Quartile(List<Expression> p) { // convert the quartile to percentile var k = (double)p[1].Evaluate() / 4; p[1] = new Expression(k); //p.Add(new Expression(k)); return Percentile(p); } //=morraf= static object Median(List<Expression> p) { // it is percentile 0.5 p.Add(new Expression(0.5)); return Percentile(p); } ``` where tally.Percentile ``` //http://stackoverflow.com/questions/8137391/percentile-calculation public double Percentile(double excelPercentile) { var values = Numerics().ToArray(); Array.Sort(values); double ret = 0; int arrayCount = values.Count(); if (arrayCount > 0) { double n = (arrayCount - 1) * excelPercentile + 1; // Another method: double n = (N + 1) * excelPercentile; if (n == 1d) return values[0]; else if (n == arrayCount) return values[arrayCount - 1]; else { int k = (int)n; double d = n - k; ret = values[k - 1] + d * (values[k] - values[k - 1]); } } return ret; } ```
↧
New Post: ClosedXML and Compact Framework
Hi,
i had the same behavior using ExcelDatareader and compact framework: it's because you can't convert full compact framework's System.data classes to compact framework 's System.Data version: Hoping the code calls existing functions and members in compact framework, your should try to create a compact framework project and import all the files of the standard project and then compile the new project... (doing this for ExcelDatareader doesn't work but maybe with this one it will work)
i had the same behavior using ExcelDatareader and compact framework: it's because you can't convert full compact framework's System.data classes to compact framework 's System.Data version: Hoping the code calls existing functions and members in compact framework, your should try to create a compact framework project and import all the files of the standard project and then compile the new project... (doing this for ExcelDatareader doesn't work but maybe with this one it will work)
↧
↧
New Post: Feature request: Initial zoom of spreadsheet
I did implement it base on kbrimington suggetstion
__IXLSheetView.cs:__
/// <summary>
/// Window zoom magnification for current view representing percent values. Horizontal & Vertical scale together.
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScale { get; set; }
/// <summary>
/// Zoom magnification to use when in normal view. Horizontal & Vertical scale together
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScaleNormal { get; set; }
/// <summary>
/// Zoom magnification to use when in page layout view. Horizontal & Vertical scale together.
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScalePageLayoutView { get; set; }
/// <summary>
/// Zoom magnification to use when in page break preview. Horizontal & Vertical scale together.
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScaleSheetLayoutView { get; set; }
__XLSheetView.cs:__
private int _zoomScale { get; set; }
public int ZoomScale
{
get { return _zoomScale; }
set
{
_zoomScale = value;
switch (View)
{
case XLSheetViewOptions.Normal:
ZoomScaleNormal = value;
break;
case XLSheetViewOptions.PageBreakPreview:
ZoomScalePageLayoutView = value;
break;
case XLSheetViewOptions.PageLayout:
ZoomScaleSheetLayoutView = value;
break;
}
}
}
public int ZoomScaleNormal { get; set; }
public int ZoomScalePageLayoutView { get; set; }
public int ZoomScaleSheetLayoutView { get; set; }
__XLWorkbook_Save.cs__
Function GenerateWorksheetPartContent
...
#region SheetViews
...
sheetView.ZoomScale = (UInt32)xlWorksheet.SheetView.ZoomScale;
sheetView.ZoomScaleNormal = (UInt32)xlWorksheet.SheetView.ZoomScaleNormal;
sheetView.ZoomScalePageLayoutView = (UInt32)xlWorksheet.SheetView.ZoomScalePageLayoutView;
sheetView.ZoomScaleSheetLayoutView = (UInt32)xlWorksheet.SheetView.ZoomScaleSheetLayoutView;
...
↧
Commented Unassigned: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0 [9142]
i am getting the following error, can someone guide me what i am missing
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Comments: robvon, I made an account to say ... thanks!
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Comments: robvon, I made an account to say ... thanks!
↧
Commented Unassigned: Excel workbook corrupt after saving [9429]
I have an xlsx workbook that is used as a template. Through a ridiculous amount of coding, I have built a library using OpenXML that _almost_ preserves all formatting of the original file after updating the cells with data. Saddened by the reams of code to accomplish this, I turned to ClosedXML and got quite far with a fraction of the code, and was very happy...until I encountered the attached spreadsheet and executed the following code.
```
var workbook = new XLWorkbook(filePath);
workbook.Save();
```
When I opened the file in Excel, I encountered the prompt to recover the contents of the workbook, since Excel found unreadable content. I clicked Yes. Excel flickered a little, and then I am presented with the alert:
> "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt."
The only hint I have found so far is that the conditional formatting elements in Sheet1.xml are different after saving through ClosedXML than before.
Comments: We are seeing the same issue here too.
```
var workbook = new XLWorkbook(filePath);
workbook.Save();
```
When I opened the file in Excel, I encountered the prompt to recover the contents of the workbook, since Excel found unreadable content. I clicked Yes. Excel flickered a little, and then I am presented with the alert:
> "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt."
The only hint I have found so far is that the conditional formatting elements in Sheet1.xml are different after saving through ClosedXML than before.
Comments: We are seeing the same issue here too.
↧