2016-08-17 119 views
0

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

代码:

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 
+0

你可以发布整个错误消息,也是什么代码行你得到的错误? – Siva

回答

1

当STARTROW = 1000,

startRow.ToString("n0")收益1000。这是Range参数的格式不正确。

你不需要使用,FormatProviderToString在这里。只需使用默认超载。

startRow.ToString() 

是你所需要的。

+1

非常感谢你 – pavilion

相关问题