DIAdem Help

Object: Font

  • Updated2024-09-12
  • 2 minute(s) read

Object: Font

The Font object corresponds to the font of a cell in an Excel worksheet.

The following example creates an Excel workbook, sets the first cell to 3.14, sets the font color of this cell to blue, and saves the Excel workbook in a new XLSX file:

VBScriptPython

 

Dim oMyWorkbook, oMySheet, oMyCell
Set oMyWorkbook = CreateExcelWorkbook() 
Set oMySheet = oMyWorkbook.Worksheets(1) 
Set oMyCell = oMySheet.Cells(1, 1)
oMyCell.Value = 3.14
oMyCell.Font.Color = RGB(0, 0, 255)
Call oMyWorkbook.SaveAs(DataWritePath & "Test.xlsx")

The following example creates an Excel workbook, fills the first workbook with random values, searches for the value 47 in the worksheet, marks the found cells with a larger red font, and saves this Excel workbook in a new XLSX file:

VBScriptPython

 

Dim iCount, jCount, oMyWorkbook, oMySheet, oMyCell, oMyNextCell
Set oMyWorkbook = CreateExcelWorkbook()
Set oMySheet = oMyWorkbook.Worksheets(1)
For iCount = 1 to 1000
  For jCount = 1 to 20
    Set oMyCell = oMySheet.Cells(iCount, jCount)
    oMyCell.Value = Round(Random(100))
  Next
Next
Set oMyNextCell = oMySheet.Find(47, eExcelSearchEquals)
Do While Not(oMyNextCell Is Nothing)
  oMyNextCell.Font.Color = RGB(255, 0, 0)
  oMyNextCell.Font.Size = 15
  Set oMyNextCell = oMySheet.Find(47, eExcelSearchEquals, oMyNextCell.Row,  oMyNextCell.Column)
Loop
Call oMyWorkbook.SaveAs(DataWritePath & "Test.xlsx")

Properties

Bold | Color | Italic | Size | Underline

Returned From

Cell.Font