Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Created Issue: ArgumentOutOfRangeException: Implementation bug in LoadFromDataTable(DataTable Table, bool PrintHeaders) [14790]

$
0
0
Hi,
There is a issue in implementation of LoadFromDataTable(DataTable Table, bool PrintHeaders) method while returning excel range base. in the above mentioned method there is issue at return statement

_worksheet.Cells[_fromRow, _fromCol, row - 1, Table.Columns.Count];

here below is a detailed description of the error:

for example i am adding data to sheet 'X' with a data table of 2 columns X 5 Rows and the start address 'C1'.
my code:
exlWorkSheet.Cells["C1"].LoadFromDataTable(dtEventsData.,false);

In this case as per the logic implemented in the method ' LoadFromDataTable' the values are as below while generating range.

_fromCol =3 (from 'C1' as my start address)
_fromRow=1 (from 'C1' as my start address)
_toRow=5 (row - 1 from method logic)
_toCol=2 ( as you are passing Table.Columns.Count as parameter to generate ExcelRange as i have a table with 2 columns only)

from the above values _toCol(2)<_fromCol(3) which is an impossible case for generating ExcelRange in the above case.

I am proposing a just a minor change:

use this code: _worksheet.Cells[_fromRow, _fromCol, row - 1, Table.Columns.Count+_fromCol];
Existing Code: _worksheet.Cells[_fromRow, _fromCol, row - 1, Table.Columns.Count];

version details:
[assembly: AssemblyVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.2.0")]




Viewing all articles
Browse latest Browse all 2262

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>