Object: Cell
- Updated2024-09-12
- 2 minute(s) read
Excel > Objects > Workbook > Worksheets > Worksheet > Object: Cell
Object: Cell
The Cell object corresponds to a cell in an Excel worksheet.
The following example creates an Excel workbook, fills the first cell with the value 3.14, and outputs this value.
| VBScript | Python |
Dim oMyWorkbook, oMySheet, oMyCell Set oMyWorkbook = CreateExcelWorkbook() Set oMySheet = oMyWorkbook.Worksheets(1) Set oMyCell = oMySheet.Cells(1, 1) oMyCell.Value = 3.14 Call MsgBox(oMyCell.Value)
The following example creates an Excel workbook, fills the first worksheet with random values, and highlights the cells containing the value 47 with a red background:
| VBScript | Python |
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.Interior.Color = RGB(255, 0, 0) Set oMyNextCell = oMySheet.Find(47, eExcelSearchEquals, oMyNextCell.Row, oMyNextCell.Column) Loop Call oMyWorkbook.SaveAs(DataWritePath & "Test.xlsx")
Properties
Column | ColumnWidth | Font | HorizontalAlignment | Interior | Row | RowHeight | Value | VerticalAlignment