EPPlus throwing Argument Exception (Negative row and column numbers are not allowed)

被刻印的时光 ゝ 提交于 2019-12-11 04:37:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!