Hello,
I am getting following error while uploading xlsx file instead of xls
Specified argument was out of the range of valid values. at Syncfusion.XlsIO.Implementation.RangeImpl.CheckRange(Int32 row, Int32 column) at Syncfusion.XlsIO.Implementation.RangeImpl.get_Item(Int32 row, Int32 column, Int32 lastRow, Int32 lastColumn) at Syncfusion.XlsIO.Implementation.HPageBreakImpl.get_Location() at Syncfusion.XlsIO.Implementation.Collections.HPageBreaksCollection.Add(HPageBreakImpl pageBreak) at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseHorizontalPagebreaks(XmlReader reader, WorksheetImpl sheet) at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseAfterSheetData(XmlReader reader, WorksheetImpl sheet, MemoryStream& streamCF, String strParentPath, Dictionary`2 dictItemsToRemove) 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) at Syncfusion.XlsIO.Implementation.WorksheetImpl.ParseData(Dictionary`2 dictUpdatedSSTIndexes) at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseWorksheets(Dictionary`2 dictUpdatedSSTIndexes) at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseWorkbook(List`1& themeColors) at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseDocument(List`1& themeColors) at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseExcel2007Stream(Stream stream, String password) 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, ExcelOpenType openType, String fileName, ExcelVersion version, ExcelParseOptions options) at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(String fileName, ExcelOpenType openType, ExcelVersion version, ExcelParseOptions options) at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(String fileName, ExcelOpenType openType, ExcelVersion version) at AuditdspUpload.ProcessAudit(Object UFile) at AuditdspUpload.DoUpload(Object Sender, EventArgs e)
I am using below code
If UCase(Right(sPath, 5)) = ".XLSX" Or UCase(Right(sPath, 5)) = ".XLSM" Then
excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2007
Else
excelEngine.Excel.DefaultVersion = ExcelVersion.Excel97to2003
End If
workbook = excelEngine.Excel.Workbooks.Open(sPath, ExcelOpenType.Automatic, ExcelVersion.Excel2007)
Can you please look at it and help me out?
Thanks,
Prakash