Sunday, 15 June 2014

asp.net - index was outside the bounds of the array USING EXCEL DATA READER -



asp.net - index was outside the bounds of the array USING EXCEL DATA READER -

filestream stream = file.open(filepath, filemode.open, fileaccess.read); //1. reading binary excel file ('97-2003 format; *.xls) iexceldatareader excelreader = excelreaderfactory.createbinaryreader(stream); //... //2. reading openxml excel file (2007 format; *.xlsx) iexceldatareader excelreader = excelreaderfactory.createopenxmlreader(stream); //... //3. dataset - result of each spreadsheet created in result.tables dataset result = excelreader.asdataset(); //... //4. dataset - create column names first row excelreader.isfirstrowascolumnnames = true; dataset result = excelreader.asdataset(); //5. info reader methods while (excelreader.read()) { //excelreader.getint32(0); } //6. free resources (iexceldatareader idisposable) excelreader.close();

i've used above code read in excel document, utilize no1 or no2 depending on wether xls or xlsx, i've tried xlsx (using number 2 above , works fine - im using plug in export document again- , works xsl, wanted maintain excel info reader 'xls' when utilize code (number 1 instead of number 2-(numbered above) error when trying read in file - index outside bounds of array

any thought why?

thaks

asp.net arrays indexing exceldatareader

No comments:

Post a Comment