Free Trial
Web API version
Licensing
Request A Quote
HAVE QUESTIONS OR NEED HELP? SUBMIT THE SUPPORT REQUEST FORM or write email to SUPPORT@BYTESCOUT.COM
Read Number Format In Cell | VB.NET


Module1.vb:
VB
Imports Bytescout.Spreadsheet Imports Bytescout.Spreadsheet.Constants Imports System.IO Module Module1 Sub Main() ' Create new Spreadsheet Dim document As New Spreadsheet() document.LoadFromFile("Data.xls") ' Get worksheet by name Dim worksheet As Worksheet = document.Workbook.Worksheets.ByName("Sample") ' Check dates For i As Integer = 0 To 7 For j As Integer = 0 To 1 ' Set current cell Dim currentCell As Cell = worksheet.Cell(i, j) ' Get format type Dim formatType As NumberFormatType = currentCell.ValueDataTypeByNumberFormatString ' Write line Console.Write("Cell({0}:{1}) type is {2}. Value : ", i, j, formatType.ToString()) Select Case formatType Case formatType.DateTime ' Read datetime Dim datm As DateTime = currentCell.ValueAsDateTime ' Write date to console output Console.Write(datm.ToString()) Case formatType.General ' Write value to console output Console.Write(currentCell.Value) End Select Console.WriteLine() Next Next ' Close document document.Close() Console.ReadKey() End Sub End Module