我正在Visual Studio中用vb中的数据(400000行)从datagridview生成Excel文件报告。
我已经尝试过此代码,当我使用“ 0”代替“ counterx”时,它可以正常工作。 但是我必须在每个循环上增加计数器,这样才能将每一行一个接一个地..后来我可以简单地使用其他循环来使事情更快。
counterx = 0
Do While (remains > 0)
Dim rawData3(0, DataGridView4.Columns.Count - 1) As Object
For col = 0 To DataGridView4.Columns.Count - 1
rawData3(0, col) = DataGridView4.Rows(counterx).Cells(col).Value
Next
counterx += 1
Dim excelstart3 As String = String.Empty
TextBox4.Text = counterx
excelstart3 = ((counterx) + 1).ToString()
TextBox8.Text = "A" & excelstart3 & ":{0}{1}"
Dim finalColLetter1 As String = String.Empty
finalColLetter1 = ExcelColName(DataGridView4.Columns.Count)
Dim excelRange3 As String = String.Format("A" & excelstart3 & ":{0}{1}", finalColLetter1, counterx + 1) 'firstphase + 1 )
Ws.Range(excelRange3, Type.Missing).Value2 = rawData3
' secondphase = secondphase - 1
remains = remains - 1
Loop