' (C) On Time Computing Solutions, 2009. All Rights Reserved.
'----------------------------------------------------------------
' Tutorial 25
'
' This tutorial shows how to export an XLSB file.
'-----------------------------------------------------------------*/
Click here to see the Excel file.
Imports ActiveXLS
Imports ActiveXLS.Constants
Module Tutorial25
Sub Main()
Console.WriteLine("Tutorial 25" & vbCrLf & "----------" & vbCrLf)
'Create an instance of the object that generates Excel files, having 2 sheets
Dim xls As New ExcelDocument(2)
'Set the sheet name
xls.esd_getSheetAt(0).setSheetName("First tab")
xls.esd_getSheetAt(1).setSheetName("Second tab")
'Get the table of the first worksheet
Dim xlsFirstTab As ExcelWorksheet = xls.esd_getSheetAt(0)
Dim xlsFirstTable = xlsFirstTab.esd_getExcelTable()
'Add the cells for header
For column As Integer = 0 To 4
xlsFirstTable.esd_getCell(0, column).setValue("Column " & (column + 1))
xlsFirstTable.esd_getCell(0, column).setDataType(DataType.STRING)
Next
'Add the cells for data
For row As Integer = 0 To 99
For column As Integer = 0 To 4
xlsFirstTable.esd_getCell(row + 1, column).setValue("Data " & (row + 1) & ", " & (column + 1))
xlsFirstTable.esd_getCell(row + 1, column).setDataType(DataType.STRING)
Next
Next
'Set column widths
xlsFirstTable.setColumnWidth(0, 70)
xlsFirstTable.setColumnWidth(1, 100)
xlsFirstTable.setColumnWidth(2, 70)
xlsFirstTable.setColumnWidth(3, 100)
xlsFirstTable.setColumnWidth(4, 70)
'Generate the file
Console.WriteLine("Writing file C:\Samples\Tutorial25.xlsb.")
xls.esd_WriteXLSBFile("C:\Samples\Tutorial25.xlsb")
'Confirm generation
Dim sError As String = xls.esd_getError()
If (sError.Equals("")) Then
Console.Write(vbCrLf & "File successfully created. Press Enter to Exit...")
Else
Console.Write(vbCrLf & "Error encountered: " & sError & vbCrLf & "Press Enter to Exit...")
End If
Console.ReadLine()
End Sub
End Module
© On Time Computing Solutions, 2009. All Rights Reserved. |