tags:

views:

37

answers:

2

I have a webpage where the user can upload an excel file. I'm trying 2 different files - one works without a problem, and the other one gives me this error:

Error: Length cannot be less than zero. Parameter name: length

I know that sometimes this occurs when the file size is zero, but that is not the case here.

Can anyon shed light on this issue? Please let me know if you need more info.

A: 

As noted, more info is needed. It's not clear if you are opening the Excel file and processing directly from it or reading the data from Excel directly to a DataTable via ODBC, or something else.

Most of my problems reading Excel files are caused either by column titles, or by data in a particular column being different types. Check first to see if your two Excel files have the same columns, all columns have names, etc.

When you read to a DataTable, the program takes a guess at the data type of each column. If the first several cells are empty, the guess may be wrong. If your data is like mine, a column that looks like it's all numbers may be half actual numbers, half strings. Or, a column of dates may have an illegal value.

I have better luck writing the data from Excel to a .csv file, and having the program write a schema.ini and read it with the Microsoft Text Driver, but that may not suit your data.

SeaDrive
A: 

Is there an update panel in your page ? I had a problem when I was trying to use FileUpload with an Update Panel in the Page.

Very weird case, i suggest you could try to make a copy of file that works and try with this to see if works too. or maybe, verify if both files were saved with the same version of Excel.

Rbacarin