TExportCell

Description

TExportCell is the abstract cell class. Do not use it directly. Use child clases instead.

Child classes

NameDescription
TExportCellEmptyEmpty cell
TExportCellStringString cell
TExportCellCustomNumberAbstract number cell
TExportCellNumberNumber cell
TExportCellPercentPercent cell
TExportCellCurrencyPercent cell
TExportCellDateDate cell
TExportCellDateTimeDatetime cell
TExportCellDateTimeWSDatetime (without seconds) cell
TExportCellTimeTime cell
TExportCellTimeWSTime (without seconds) cell

Properties

NameTypeDescription
RowTExportRowRow where the cell is placed.
ColTExportColColumn where the cell is placed.
RowIndexIntegerRead-only index of the row (zero-based).
ColIndexIntegerRead-only index of the column (zero-based).
RangeNoSpanStringExcel range of the top-left corner of the cell. (E.g. "A1", "C15" etc.).
RangeWithSpanStringExcel range of the cell with column/row span. (E.g. "A1:B1", "C15:E15" etc.)
If the cell has RowSpan = 1 and ColSpan = 1, this property is equal to RangeNoSpan.
ColSpanIntegerColumn span
RowSpanIntegerRow span
ValueAssignedBooleanDefines if a valid value is assigned to the cell. If false and a formula is assigned, the value will be calculated automatically by OExport.
NameOWideStringThe defined name of the cell. The actual names are saved in the TOExport.NamedCells: TExportNamedCells object.
StyleTExportCellStyleFormatting style of the cell.
AlignmentTCellHAlignmentHorizontal alignment
VAlignmentTCellVAlignmentVertical alignment
FontTExportFontFont
BGColorTColorBackground color
BordersTExportCellBordersBorder
OrientationTExportFlowOrientationText orientation:
  • efoLeftToRight: left-to-right (normal)
  • efoTopToBottom: top-to-bottom (every character will be on a new line)
RotationTExportCellRotationText rotation in degrees. Value range: -90..90.
Applicable only when Orientation is efoLeftToRight.
WrapTextBooleanWord wrap
WidthIntegerColumn width. This property reads/writes the Col.Width property of the appropriate worksheet column.
HeightIntegerRow height. This property reads/writes the Row.Height property of the appropriate worksheet row.
CalculateColWidthBooleanSet to true if the column width should be calculated automatically from the cell text.
Applicable only if WrapText = False, Orientation = efoLeftToRight, Rotation = 0 and ColSpan = 1.
If more cells within a column have CalculateColWidth = True, the maximum width from the cells is calculated.
Important: Column width and row height calculation works also for single-line cells with rich formatting. Multi-line cells with rich formatting are calculated like they were without formatting.
DrawingsTExportCellDrawingsList with drawings in the cell (images / charts).
Use DrawingsAssigned to check if Drawings exist in the cell.
DrawingsAssignedBoolean Use DrawingsAssigned to check if Drawings exist in the cell.
ConditionalFormattingTExportConditionalFormattingConditional formatting
Use ConditionalFormattingAssigned to check if ConditionalFormatting exists in the cell.
ConditionalFormattingAssignedBoolean Use ConditionalFormattingAssigned to check if ConditionalFormatting exists in the cell.
DataValidationTExportDataValidationData validation
Use DataValidationAssigned to check if DataValidation exists in the cell.
DataValidationAssignedBoolean Use DataValidationAssigned to check if DataValidation exists in the cell.
CommentTExportCellCommentComment
Use CommentAssigned to check if Comment exists in the cell.
ConditionalFormattingAssignedBoolean Use CommentAssigned to check if Comment exists in the cell.
FormulaOWideStringThe formula value.
Note that you can use Excel/Calc functions in the formula that have to be in english language.
If formula is set, you don't need to assign the result value - it will be automatically calculated by Excel or Calc.
Please see Formula recalculation engine for more information about formulas in OExport.
SqlTextOWideStringCell value formatted as SQL text. For string cells, no formatting is used.
Example: Datetime 2004-05-20 12:30:06, Float 158.123. For number cells with a formula, the result value is returned.
FormattedTextOWideStringCell value formatted as you can see it in Excel/Calc.
Example: Datetime 24.01.2013 19:41:21, Float 15,1254, Currency $ 15.000,00 etc.

Functions & procedures

function Set*(const *): TExportCell;
The Set* functions set the appropriate cell property and return Self (the cell object). Thanks to this, more Set* functions can be called in one line.
Example:
//var xCell: TExportCell;
xCell.SetFontName('Arial').SetFontSize(15).SetFontColor(clRed);
function AddImage(const aFileName: OWideString;
const aLeft, aTop, aWidth, aHeight: Integer): TExportCellDrawing; overload;
Adds an image from a file into the cell. aFileName must be a valid file path with a valid image extension (e.g. C:\flower.png). aLeft, aTop is the offset from upper-left border of the cell, aWidth, aHeight are the dimensions of the image.
Code snippets for adding images.
function AddImage(const aStream: TStream; const aFileName: OWideString;
const aLeft, aTop, aWidth, aHeight: Integer): TExportCellDrawing; overload;
Adds an image from a stream into the cell. aFileName must be a valid file name with a valid image extension (e.g. flower.png).
Code snippets for adding images.
function ReuseImage(const aDrawingIndex: Integer;
const aLeft, aTop, aWidth, aHeight: Integer): TExportCellDrawing;
Places an image that has already been added to a different cell with AddImage function. Use aDrawingIndex to indicate the image. A chart can be placed only once in an document.
Code snippets for adding images.
function AddChart(const aChartType: TExportChartClass;
const aLeft, aTop, aWidth, aHeight: Integer): TExportCellDrawing;
Adds an empty chart into the cell. Please read the Chart classes section for more information.
Code snippets for adding charts.
function Transform(const aCellClass: TExportCellClass): TExportCell;
Transforms the cell to desired type. All properties of the cell stay untouched. OExport tries to re-assign the cell value. The value is kept between all numeric cells (number, date, currency etc) but not if you transform a string cell to a number etc.
Important: the cell may be destroyed and a new cell may be created at it's place!
function SetExcelNumberFormat(const aValue: OWideString; const aParse: Boolean): TExportCell;
Assign a custom excel number format to a cell. If you specify aParse = true, OExport tries to parse the format and use it for ODS/CSV export.
Important: Use english formatting strings!!!
Examples of formatting strings:
  • Number with 2 decimal places and a thousands separator: "#,##0.00"
  • Currency: "€ #,##0.00"
  • Date: "dd/mm/yyyy", "yyyy-mm-dd"
  • Time: "hh:mm:ss", "h:mm am/pm"
function SetExcelNumberFormatAndTransform(const aValue: OWideString): TExportCell;
This is a combination of SetExcelNumberFormat(aValue, True) and Transform.
The new excel number format will be applied to the cell and the cell will be transformed to the desired type.
procedure StyleAssignFromCol;
Assign cell style from the column.
procedure StyleAssignFromRow;
Assign cell style from the row.
procedure StyleAssignFromSheet;
Assign cell style from the worksheet.
procedure StyleClear;
Clears the style (it calls Style.Clear).
Categories