I have a spreadsheet that was working as a template (using ClosedXML to add data to the template). After opening the template with Excel 2010 and saving it (no other changes), it began to fail on Save() in ClosedXML.
After downloading the ClosedXML source, and running it in debug, the failure is in the XLCell.cs in the "GetA1Column" method when it is passed a columnPart = "C-".
You can duplicate this with a very simple spreadsheet. Enter the formula "=IF(ISERROR(B1-(B2)),0,B1-(B2))" in cell B3. Drag the formula across to E3 (copies the formula into C3, D3, and E3). Save the spreadsheet as "C:\Test.xslx".
Create a Console program (I used the ClosedXML_Sandbox) that opens and tries to save the Text.xlsx spreadsheet, it should fail in the GetA1Column method (on the line "columnToReturn = XLHelper.GetColumnLetterFromNumber(Address.ColumnNumber + Int32.Parse(columnPart.Substring(mIndex)) + columnsToShift);" with the error
"System.FormatException was unhandled
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
After downloading the ClosedXML source, and running it in debug, the failure is in the XLCell.cs in the "GetA1Column" method when it is passed a columnPart = "C-".
You can duplicate this with a very simple spreadsheet. Enter the formula "=IF(ISERROR(B1-(B2)),0,B1-(B2))" in cell B3. Drag the formula across to E3 (copies the formula into C3, D3, and E3). Save the spreadsheet as "C:\Test.xslx".
Create a Console program (I used the ClosedXML_Sandbox) that opens and tries to save the Text.xlsx spreadsheet, it should fail in the GetA1Column method (on the line "columnToReturn = XLHelper.GetColumnLetterFromNumber(Address.ColumnNumber + Int32.Parse(columnPart.Substring(mIndex)) + columnsToShift);" with the error
"System.FormatException was unhandled
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int32.Parse(String s)
at ClosedXML.Excel.XLCell.GetA1Column(String columnPart, Int32 columnsToShift) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCell.cs:line 1831
at ClosedXML.Excel.XLCell.GetA1Address(String r1C1Address, Int32 rowsToShift, Int32 columnsToShift) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCell.cs:line 1807
at ClosedXML.Excel.XLCell.GetFormula(String strValue, FormulaConversionType conversionType, Int32 rowsToShift, Int32 columnsToShift) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCell.cs:line 1762
at ClosedXML.Excel.XLCell.GetFormulaA1(String value) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCell.cs:line 1738
at ClosedXML.Excel.XLCell.get_FormulaA1() in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCell.cs:line 937
at ClosedXML.Excel.XLCell.get_InnerText() in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCell.cs:line 139
at ClosedXML.Excel.XLWorkbook.<GenerateSharedStringTablePartContent>b__df(IXLCell c) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 700
at ClosedXML.Excel.XLCellsCollection.<GetCells>d__1a.MoveNext() in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\Cells\XLCellsCollection.cs:line 418
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at ClosedXML.Excel.XLWorkbook.GenerateSharedStringTablePartContent(SharedStringTablePart sharedStringTablePart, SaveContext context) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 696
at ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 133
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath, SpreadsheetDocumentType spreadsheetDocumentType) in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 91
at ClosedXML.Excel.XLWorkbook.Save() in c:\Development\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 417
at ClosedXML_Sandbox.Program.Main(String[] args) in c:\Development\ClosedXML\ClosedXML\ClosedXML_Sandbox\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: