Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Aspose.Cells
Imports System.Data
Namespace LightOoxmlTest
Friend Class Program
Public Shared Sub Main(ByVal args() As String)
'Specify your desired matrix
Dim rowsCount As Integer = 1000000
Dim colsCount As Integer = 3
Dim workbook = New Workbook()
Dim ooxmlSaveOptions = New OoxmlSaveOptions()
ooxmlSaveOptions.LightCellsDataProvider = New TestDataProvider(workbook, rowsCount, colsCount)
workbook.Save(“e:\test2\myoutput_test1.xlsx”, ooxmlSaveOptions)
End Sub
End Class
Friend Class TestDataProvider
Inherits LightCellsDataProvider
Private dt As DataTable
Public Sub FillTable()
dt = New DataTable()
dt.Columns.Add(“Column1”, GetType(Integer))
dt.Columns.Add(“Column2”, GetType(String))
dt.Columns.Add(“Column3”, GetType(Integer))
For i As Integer = 0 To maxRows - 1
dt.Rows.Add(i \ 10 + 1, String.Format(“Item {0}”, i), i)
Next i
End Sub
Private _row As Integer = -1
Private _column As Integer = -1
Private maxRows As Integer
Private maxColumns As Integer
Private _workbook As Workbook
Public Sub New(ByVal workbook As Workbook, ByVal maxRows As Integer, ByVal maxColumns As Integer)
Me._workbook = workbook
Me.maxRows = maxRows
Me.maxColumns = maxColumns
FillTable()
End Sub
#Region “LightCellsDataProvider Members”
Public Function IsGatherString() As Boolean
Return False
End Function
Public Function NextCell() As Integer
_column += 1
If _column < Me.maxColumns Then
Return _column
Else
_column = -1
Return -1
End If
End Function
Public Function NextRow() As Integer
_row += 1
If _row < Me.maxRows Then
_column = -1
Return _row
Else
Return -1
End If
End Function
Public Sub StartCell(ByVal cell As Cell)
cell.PutValue(dt.Rows(_row)(_column)) '_row + _column);
End Sub
Public Sub StartRow(ByVal row As Row)
End Sub
Public Function StartSheet(ByVal sheetIndex As Integer) As Boolean
If sheetIndex = 0 Then
Return True
Else
Return False
End If
End Function
#End Region
End Class
End Namespace