Question about ImportFromDataReader (exceptional) boundary conditions


#1

Laurence, for the code below, could you please tell me what exceptions the ImportFromDataReader could throw? I am particularly interested in boundary conditions, like for large amounts of data. What are the break points?

using (IDataReader reader = db.ExecuteReader(command))
{
cells.ImportFromDataReader((SqlDataReader)reader, 1, 0, true);
}

Thanks.


#2

In an Excel file, each worksheet can only contains 65536rows and 256 columns.

So when you call this method, please make sure that

firstRow + number of rows <= 65536

firstColumn + number of columns <= 256

Otherwise, an exception will be thrown.


#3

Thank you. What is the Type of the Exception, if I were to catch it in a try/catch block?


#4

It will throw ArgumentException in this case.


#5

No, my mistake. ArgumentException will be only thrown when the first row or column index is out of range. When number of rows or columns in DataReader is out of range, no exception will be throw. However, data will be truncated to be filled into the worksheet.


#6

Very good. Thank you.