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



所以在我的vb.net应用程序中,我正在从数据库中提取数据(表中约1046行)以预加载excel电子表格中的内容。在999行之前可以正常工作,但如果超过999行,就会给出那个特定的错误。我想知道是否有限制。什么好主意吗?我使用的是windows 10, management studio 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")返回1000。Range参数的格式不正确。

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

startRow.ToString()

相关内容

  • 没有找到相关文章