Question about ImportFromDataReader (exceptional) boundary conditions


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);



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.


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


It will throw ArgumentException in this case.


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.


Very good. Thank you.