ReadingSamplesVB

Back to features

Imports GemBox.Spreadsheet
 
Module Module1
 
    Sub Main()
        ' TODO: If using GemBox.Spreadsheet Professional, put your serial key below.
        ' Otherwise, if you are using GemBox.Spreadsheet Free, comment out the 
        ' following line (Free version doesn't have SetLicense method). 
        ' SpreadsheetInfo.SetLicense("YOUR-SERIAL-KEY-HERE")
 
        Dim ef As ExcelFile = New ExcelFile
        Dim sheet As ExcelWorksheet
        Dim row As ExcelRow
        Dim cell As ExcelCell
 
        ef.LoadXls("..\TestWorkbook.xls")
        ' Uncomment if you want to read from XLSX or ODS. Preservation option must be specified 
        ' to read cached formula values (otherwise formulas will have empty result value).
        'ef.LoadXlsx("..\TestWorkbook.xlsx", XlsxOptions.PreserveMakeCopy)
        'ef.LoadOds("..\\TestWorkbook.ods", OdsOptions.PreserveMakeCopy)
 
        For Each sheet In ef.Worksheets
            Console.WriteLine("--------- {0} ---------", sheet.Name)
 
            For Each row In sheet.Rows
                For Each cell In row.AllocatedCells
                    If Not cell.Value Is Nothing Then
                        Console.Write("{0}({1})", cell.Value, cell.Value.GetType().Name)
                    End If
 
                    Console.Write(vbTab)
                Next
 
                Console.WriteLine()
            Next
        Next
 
        Console.ReadLine()
    End Sub
 
End Module