Следующий код работает, пока я не использую большое количество записей. Есть ли способ использовать партии, скажем, 1000 записей одновременно.
Dim ws As Object = GetWorksheet(handle, workbookname, worksheetname)
Dim origin As Object = ws.Range(cellref, cellref)
Dim cell As Object = origin
Dim colInd As Integer = 0, rowInd As Integer = 0 ' Offsets from the origin cell
' Deal with the column names first
If includecolnames Then
For Each col As DataColumn In Collection.Columns
Try
cell = origin.Offset(rowInd, colInd)
Catch ex As Exception ' Hit the edge.
Exit For
End Try
SetProperty(cell, "Value", col.ColumnName)
colInd += 1
Next
rowInd += 1
End If
' Now for the data itself
For Each row As DataRow In Collection.Rows
colInd = 0
For Each col As DataColumn In Collection.Columns
Try
cell = origin.Offset(rowInd, colInd)
Catch ex As Exception ' Hit the edge.
Exit For
End Try
'MessageBox.Show("RowOffset:" & rowInd & "; ColOffset:" & colInd & "; cell: " & cell.Address(False,False))
SetProperty(cell, "Value", row(col))
colInd += 1
Next
rowInd += 1
Next
Как только я использую более 20000 записей, я получаю следующее исключение System.OutOfMemoryException