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

ArgumentOutOfRangeException

Are there any known issues with XlsIO accessing file that have (or had and have removed) sheet protection? I'm getting an ArgumentOutOfRangeException (Parameter name:length; Actual value was 3) trying to open a work book using the following code snipit:
Thanks for any help,
Mike

Dim strFilename As String = "c:\myfile.xls"
Dim excelEngine As ExcelEngine = New ExcelEngine()
Dim application As IApplication = excelEngine.Excel
Dim workbook As IWorkbook = application.Workbooks.Open(strFilename)

10 Replies

CP Chella Pandian B Syncfusion Team December 4, 2006 11:24 PM UTC

Hi Mike

I am unable to reproduce the issue. I was able to access the file that had and have removed sheet protection. So can you please forward us the sample file which reproduces such issue. It will be help full for our investigation. Sorry for the Inconvenience.

With regards,
Chella.




TE Teddy April 19, 2022 03:30 AM UTC

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



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team April 20, 2022 12:11 PM UTC

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.



RS Ramya Sivakumar Syncfusion Team April 22, 2022 04:34 PM UTC

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



RS Ramya Sivakumar Syncfusion Team May 3, 2022 11:32 AM UTC

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



RH rider huynh replied to Ramya Sivakumar September 8, 2022 10:15 AM UTC

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


Attachment: CannotOpenExcelFile_a41ed4db.zip


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team September 9, 2022 06:31 AM UTC

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.



RH rider huynh replied to Konduru Keerthi Konduru Ravichandra Raju September 9, 2022 08:41 AM UTC

Hi   Keerthi ,


Thanks for the help of the team, we will wait for the next update.


Thanks & Best Regards ,

Rider



RS Ramya Sivakumar Syncfusion Team September 12, 2022 02:26 PM UTC

Hi Rider,


You're welcome.  We will get back to you by tomorrow.


Regards,
Ramya



RS Ramya Sivakumar Syncfusion Team September 13, 2022 12:53 PM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon