ExcelWriter Xojo Plugin

ExcelWriterWorksheet.CellDateValue Method

Sets date of a cell in given row and column, using given formatting object.

CellDateValue(
   column as UInt32,
   row as UInt32,
   formatting as ExcelWriterFormat) as Date

Parameters

column
The column number to put the text in (zero based)
row
The row number to put the text in (zero based)
formatting
The formatting object to be used or nil if defaults should be used.

Returns

Date

Remarks

When this method is called then error hints are written in the LastError property.

Dim f as FolderItem

f = GetSaveFolderItem("*.*","Displaying formatted date.xlsx")

if f <> nil then
    Dim writer as ExcelWriterWorkbook = ExcelWriterWorkbook.Create(f, ZStream.GetZipEngineHandle())
    Dim sheet as ExcelWriterWorksheet = writer.AddWorksheet()
    Dim format as ExcelWriterFormat = writer.AddFormat()
   
    sheet.ColumnWidth(2,2) = 30 // Make the column wider so we can actually see the formatted date
   
    format.SetPresentationFormat("mmm d yyyy hh:mm AM/PM")
   
    sheet.CellDateValue(2,2,format) = new Date()
   
    call writer.Close()
end if

See Also

ExcelWriterWorksheet Class