Excel Interop工作表HRESULT:0x800A03EC使用VB.net

所以在我的vb.net应用程序中,我从数据库中提取数据(表中大约有1046行),以便在Excel电子表格中预加载内容。 这工作正常,直到999行,但如果超过999行,它给了我特定的错误。 只是想知道是否有限制。 有任何想法吗? 我使用的是Windows 10,pipe理工作室2012和Excel 2007。

码:

Private Sub readEmployee(ByVal employee As data.employeeList) Dim excelWorkSheet As Excel.Worksheet Dim startRow As Integer = 9 Dim firstNames As String = "" Dim lastNames As String = "" With excelWorkSheet startRow = 9 Dim row As data.employeeList.employeeListRow For Each row In employee.employeeList If row.RowState <> DataRowState.Deleted Then firstNames = CStr(IIf(row.FirstName.Trim() = "", "", row.FirstName.Trim())) lastNames = CStr(IIf(row.LastName.Trim() = "", "", row.LastName.Trim())) .Range("A" + startRow.ToString("n0")).Value = lastNames .Range("B" + startRow.ToString("n0")).Value = firstNames startRow += 1 End If Next End With End Sub 

当startRow = 1000时,

startRow.ToString("n0")返回1,000。 这是Range参数的格式不正确。

这里你不需要使用FormatProvider for ToString 。 只需使用默认的重载。

 startRow.ToString() 

是你所需要的全部。