We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Exception while opening Excel workbook

Hi, I am using the Syncfusion ExcelRW component 3.0.1.0. I am trying to open some particular Excel sheet, used by some of our business users, using the following code. try { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = null; IWorksheet worksheet = null; workbook = ExcelUtils.Open("C:\\Temp.xls"); } catch(Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } The above code throws an exception “Specified argument was out of range of valid values”. However if I try to open a simple Excel sheet, it does not throw any exception. Please could you let me know why this should happen? Thanks, Gaurav.

2 Replies

AD Administrator Syncfusion Team August 4, 2005 05:18 AM UTC

Hi Gaurav, 1) There are two possible reasons for this, a) The file was produced by a third party vendor like XlsIO which have bugs in creating the correct file structure. This is mainly because the BIFF8 file format information published by Microsoft is incomplete and a lot of records are undocumented so the developers have to rely on trial and error to find out the undocumented Biff record structures. However, this process can be error prone and it causes imperfect BIFF8 files to be produced. The reason why Microsoft Excel is able to view these damaged files is that MS Excel has a lot more information about the file format, so it is able to guess wrong records and repair them when necessary. b) Essential ExcelRW can also give this error when it is not able to parse some file created by MS Excel. In this scenario, ExcelRW is identified to have a bug and the parsing is corrected in ExcelRW since the records found in MS Excel created files cannot be faulty. Could you please send the file that you are trying to open so that we can fix this issue soon. It''s also possible that this issue has already been fixed in version 3.2.1.0, so you could also try this version by logging on to to Direc-Trac. Thanks, Stephen. >Hi, > >I am using the Syncfusion ExcelRW component 3.0.1.0. I am trying to open some particular Excel sheet, used by some of our business users, using the following code. > >try >{ >ExcelEngine excelEngine = new ExcelEngine(); >IApplication application = excelEngine.Excel; > >IWorkbook workbook = null; >IWorksheet worksheet = null; > >workbook = ExcelUtils.Open("C:\\Temp.xls"); >} >catch(Exception ex) >{ >System.Windows.Forms.MessageBox.Show(ex.Message); >} > >The above code throws an exception “Specified argument was out of range of valid values”. > >However if I try to open a simple Excel sheet, it does not throw any exception. > >Please could you let me know why this should happen? > >Thanks, >Gaurav. >


HA harishchepuri December 14, 2012 11:56 AM UTC

Hi,
wt is the solution for this problem ,
Message : ErrorMessage :Specified argument was out of the range of valid values.
Parameter name: firstRow or lastRow
StackTrace :   at Syncfusion.XlsIO.Implementation.RangeImpl..ctor(IApplication application, Object parent, Int32 firstCol, Int32 firstRow, Int32 lastCol, Int32 lastRow)
   at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateRange(Object parent, Int32 firstCol, Int32 firstRow, Int32 lastCol, Int32 lastRow)
   at Syncfusion.XlsIO.Implementation.RangeImpl.get_Item(Int32 row, Int32 column, Int32 lastRow, Int32 lastColumn)
   at Syncfusion.XlsIO.Implementation.HyperLinkImpl.get_Range()
   at Syncfusion.XlsIO.Implementation.HyperLinkImpl.get_TextToDisplay()
   at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseHyperlink(XmlReader reader, WorksheetImpl sheet, HyperLinksCollection hyperlinks, RelationCollection relations)
   at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseHyperlinks(XmlReader reader, WorksheetImpl sheet)
   at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseAfterSheetData(XmlReader reader, WorksheetImpl sheet, MemoryStream& streamCF, String strParentPath, Dictionary`2 dictItemsToRemove)

regards,
Harish

Loader.
Live Chat Icon For mobile
Up arrow icon