I have the same issue. This is my code
using Syncfusion.XlsIO;
try
{
var ms = new MemoryStream();
var file = "c:\\Import Template (5).xlsx";
var stream = new FileStream(file, FileMode.Open, FileAccess.Read);
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open(stream);
workbook.SaveAs(ms, ExcelSaveType.SaveAsXLS);
}
}
catch (Exception ex)
{
throw;
}
Exception:
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values
Stack trace:
at Syncfusion.XlsIO.Implementation.Collections.CellRecordCollection.Add(ICellPositionFormat value)
at Syncfusion.XlsIO.Implementation.Collections.CellRecordCollection.SetSingleStringValue(Int32 iRow, Int32 iCol, Int32 iXFIndex, Int32 iSSTIndex)
at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseCell(XmlReader reader, IInternalWorksheet sheet, List`1 arrStyles, Int32 rowIndex, Int32 columnIndex, List`1 cellStyleIndex)
at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseRow(XmlReader reader, IInternalWorksheet sheet, List`1 arrStyles, String cellTag, Int32 generatedRowIndex)
at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseSheetData(XmlReader reader, IInternalWorksheet sheet, List`1 arrStyles, String cellTag)
at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseSheet(XmlReader reader, WorksheetImpl sheet, String strParentPath, MemoryStream& streamStart, MemoryStream& streamCF, List`1 arrStyles, Dictionary`2 dictItemsToRemove, Dictionary`2 dictUpdatedSSTIndexes)
at Syncfusion.XlsIO.Implementation.XmlSerialization.WorksheetDataHolder.ParseWorksheetData(WorksheetImpl sheet, Dictionary`2 dictUpdateSSTIndexes, Boolean parseOnDemand)
at Syncfusion.XlsIO.Implementation.WorksheetImpl.ParseData(Dictionary`2 dictUpdatedSSTIndexes)
at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseWorksheets(Dictionary`2 dictUpdatedSSTIndexes, Boolean parseOnDemand)
at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseWorkbook(List`1& themeColors, Boolean parseOnDemand)
at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseDocument(List`1& themeColors, Boolean parseOnDemand)
at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseExcel2007Stream(Stream stream, String password, Boolean parseOnDemand)
at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseStream(Stream stream, String password, ExcelVersion version, ExcelParseOptions options)
at Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, Stream stream, ExcelParseOptions options, ExcelVersion version)
at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, Stream stream, ExcelVersion version, ExcelParseOptions options)
at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version, ExcelParseOptions options)
at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelVersion version)
at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream, ExcelOpenType openType)
at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(Stream stream)
at Program.<Main>$(String[] args) in C:\SourceCode\MyProject\ConsoleApp1\ConsoleApp1\Program.cs:line 13
Note: when i try to open the file, enable editing and save again, It works well.
Thanks for any help.
Attachment: testfile_266269d3.7z
Hi
Greetings from Syncfusion.
We are able to reproduce the reported issue at our end and validating it currently. We will share the validation details on April 22nd, 2022.
Regards,
Keerthi.
Hi Mike,
We appreciate your patience.
We have confirmed the issue as an Exception is thrown while parsing the cell value with inlinestr type and logged a defect report. We will include the fix for this issue in our upcoming weekly NuGet release scheduled for May 3, 2022.
You can track the status of the defect report through the following feedback link.
Track Status:https://www.syncfusion.com/feedback/34385/exception-is-thrown-while-parsing-the-cell-value-with-inlinestr-type
We will let you know once the new package version is available on nuget.org.
Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
Regards,
Ramya
Hi Mike,
We appreciate your patience.
We have included the fix to resolve the issue Exception is thrown while parsing the cell value with inlinestr type in our weekly NuGet release version 20.1.0.52. Kindly upgrade your Syncfusion packages to this new 20.1.0.52 version and let us know if the issue is resolved.
Regards,
Ramya
Hi @Ramya and Syncfusion team,
I just got the same error in version 20.1.0.58 with .net 6.0, and also happen with latest version 20.2.0.48, could you help me to check again? I have attached the sample source code and the excel file causing the error below.
Thanks & Best Regards ,
Rider
Hi rider huynh,
Greetings from Syncfusion.
The Excel document which is shared in this recent issue reproducing sample
is different from the previous one for which we have validated and fixed the
issue. For this new Excel document, we are able to reproduce the
reported issue even in 20.1.0.52 and also
later versions.
We are validating this and will share the validation details in 2 business days, on September 13th, 2022.
Regards,
Keerthi.
Hi Keerthi ,
Thanks for the help of the team, we will wait for the next update.
Thanks & Best Regards ,
Rider
Hi Rider,
You're welcome. We will get back to you by tomorrow.
Regards,
Ramya
Hi Rider,
In the given Excel file, the third-row element is repeated more than one time in the XML. So collection already contains such member exception is thrown from XlsIO. To resolve this issue, we suggest you resave the Excel document in Microsoft Excel and use that resaved file in XlsIO.
Regards,
Ramya