Subject: Workbooks.Open(...) Throws Exception for CSV/TSV With 65537 or Greater Records
Date: 2020-04-11 22:20:28
From: iokevins
Source: workbooks-open-throws-exception-csv-tsv-65537-records
----------------------------------------------------------------------

How do I open CSV/TSV files with more than 65536 records?


This throws "**Specified argument was out of the range of valid values**" for a CSV/TSV file with 65537 or greater records:

    Dim ReportWorkbook As Workbook = (New WorkbookManager() With {.SheetsInNewWorkbook = 1,
                                                                  .StandardFont = "Arial",
                                                                  .StandardFontSize = 12}
                                     ).Workbooks.Open(stream:=filePath.PostedFile.InputStream)

So does this (filename, not stream): 

    Dim ReportWorkbook As Workbook = (New WorkbookManager() With {.SheetsInNewWorkbook = 1,
                                                                  .StandardFont = "Arial",
                                                                  .StandardFontSize = 12}
                                     ).Workbooks.Open(filename:=Server.MapPath(path:="~\\InputFile.csv"))

Both code samples succeed with **CSV/TSV** files with less than 65536 records. 

Both code samples succeed with **XLSX** files of greater or less than 65536 records.

StackTrace:

       at ComponentPro.Excel.Range.CheckRange(Int32 row, Int32 column)
       at ComponentPro.Excel.Range.get_Item(Int32 row, Int32 column)
       at ComponentPro.Excel.Worksheet.Parse(TextReader streamToRead, String separator, Int32 row, Int32 column, Boolean isValid)
       at ComponentPro.Excel.Workbook..ctor(WorkbookManager application, Object parent, Stream stream, String separator, Int32 row, Int32 column, ExcelVersion version, String fileName, Encoding encoding)
       at ComponentPro.Excel.WorkbookManager.CreateWorkbook(Object parent, Stream stream, String separator, Int32 row, Int32 column, ExcelVersion version, String fileName, Encoding encoding)
       at ComponentPro.Excel.Collections.WorkbookCollection.c_723e584f(Stream , String , Int32 , Int32 , String , Encoding , ExcelVersion )
       at ComponentPro.Excel.Collections.WorkbookCollection.Open(Stream stream, ExcelOpenType openType)
       at Project.import.btnImport_Click(Object sender, EventArgs e) in C:\Path\import.aspx.vb:line 180


**ENVIRONMENT** 

 - UltimateDocExpert v7.2.234.86 (latest)
 - Microsoft Visual Studio Community 2019 16.5.3 (latest)
 - .NET Framework 4.8
 - Web forms application
 - Microsoft Windows 10 Pro, v10.0.18362 Build 18362

Thank you

Kevin

  [1]: http://dq.cde.ca.gov/dataquest/dlfile/dlfile.aspx?cLevel=School&cYear=2018-19&cCat=Enrollment&cPage=filesenr.asp
  [2]: https://www.cde.ca.gov/ds/sd/sd/filesenr.asp

----------------------------------------------------------------------

Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index