问题
I'm using EPPlus 2.9.0.1 with Visual Basic.
I have a DataTable with 35 Rows and 4 Columns and the code below:
Dim FullFilePath As String = "c:\Report.xlxs"
Dim newFile As FileInfo = New FileInfo(FullFilePath)
Using package As ExcelPackage = New ExcelPackage(newFile)
Dim worksheet As ExcelWorksheet = package.Workbook.Worksheets.Add("Relatório")
worksheet.Cells.LoadFromDataTable(gSystemTable, False)
package.Save()
End Using
When method 'LoadFromDataTable' is called, I get an ArgumentException (Negative row and Columns numbers are not allowed). I don't have negative numbers in row or column numbers, as far I know.
Why this error is happening?
回答1:
You need to specify the range where you want to add the data to the worksheet.
For example:
worksheet.Cells("A1").LoadFromDataTable(gSystemTable, False)
来源:https://stackoverflow.com/questions/7953713/epplus-throwing-argument-exception-negative-row-and-column-numbers-are-not-allo