- #How do i convert an excel 97 to the latest version of excel how to
- #How do i convert an excel 97 to the latest version of excel install
Every DataTable will be converted to one worksheet. Worksheet.Cells(count, 0) = New Cell( " ")īasically, the code above traverses DataTables and DataRows inside DataSet, then converts it into Excel workbook file. Next End If ' Bug on Excel Library, min file size must be 7 Kb ' thus we need to add empty row for safety If iTotalRows < 100 Then IRow = iRow + 1 Next ' Attach worksheet to workbook Worksheet.Cells(iRow, iCol) = New Cell(sTemp) Worksheet.Cells(iRow, iCol) = New Cell(dTemp, " #,#0.00") Worksheet.Cells(iRow, iCol) = New Cell(dtTemp, " MM/DD/YYYY") ICol = 0 For Each dc As DataColumn In dt.Columns IRow = 1 For Each dr As DataRow In dt.Rows Worksheet.Cells(iRow, iCol) = New Cell(dc.ColumnName) ' Write Table Header For Each dc As DataColumn In dt.Columns Worksheet = New Worksheet( " Sheet " & iSheetCount.ToString()) To use ExcelLibrary, we will need to import ExcelLibrary class to the page level (*.aspx.vb):Ĭopy Code Public Function WriteXLSFile( ByVal pFileName As String, ByVal pDataSet As DataSet) As Boolean Try ' This function CreateWorkbook will cause xls file cannot be opened ' normally when file size below 7 KB, see my work around below ' (pFileName, pDataSet) ' Create a workbook instance Dim workbook As Workbook = New Workbook()ĭim iRow As Integer = 0 Dim iCol As Integer = 0 Dim sTemp As String = String.Emptyĭim dTemp As Double = 0 Dim iTemp As Integer = 0 Dim dtTemp As DateTimeĭim count As Integer = 0 Dim iTotalRows As Integer = 0 Dim iSheetCount As Integer = 0 ' Read DataSet If Not pDataSet Is Nothing And > 0 Then ' Traverse DataTable inside the DataSet For Each dt As DataTable In pDataSet.Tables
#How do i convert an excel 97 to the latest version of excel how to
So we will need to Add Reference in our project to it (see how to add reference here). Basically it is a library file in *.dll format. This tip will include the work around for this bug.ĮxcelLibrary is very easy to use. When generated Excel workbook file size is below 7 KB, it will show warning when you try to open using Microsoft Excel. ExcelLibrary also has one well known bug. In other words, it is using BIFF8 file format. It is under GNU Lesser GPL license, which means it can be used by commercial applications.ĮxcelLibrary supports Microsoft Excel 97-2003 workbook file format. In this tips, I will use ExcelLibrary which can be downloaded here (choose the latest version).
#How do i convert an excel 97 to the latest version of excel install
There are a lot of third party libraries as well which do not require to install Microsoft Excel in web servers. NET framework which requires us to install Microsoft Excel in web servers, which you can read about it here.
There are several ways to write an Excel workbook file ( *.xls) in VB.NET.