TExportCell → TExportCellString
Use TExportCellString for string cells.
Name | Type | Description |
---|---|---|
Text | OWideString | Text value of the cell. Please note that if you use rich text formatting in the cell, the formatting will be deleted when you change the text property. Use AppendFormattedText* if you need to append some string to the cell text without losing formatting. |
UseSharedStrings | Boolean | Excel only: when set to true, the text will be added
to shared strings (suitable if the cell text is present in many different cells). Otherwise
the text will be saved directly in the cell value. This property does not have any effect on OOo Calc documents. |
HyperLink | OWideString | The text/cell will be a clickable hyperlink.
Don't forget to use proper protocol. Examples: http://www.kluug.at, mailto:spambox@kluug.at |
RichTextTags | TStringRichTextTags | List of rich text tags applied on the cell. 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. |
function AppendFormattedText*(const aText: OWideString; *): TExportCellString; |
---|
The AppendFormattedText* functions append aText to current cell text with the formatting you specify. |
function ApplyRichTextFormatting*(const aStartChar, aLength: Integer; *): TExportCellString; |
The ApplyRichTextFormatting* functions apply a new formatting on the selection defined by aStartChar and aLength (aStartChar is 1-based). |
uses OExportRTF; procedure AddWorkSheet_RTF(xExport: TOExport); var xCell: TExportCellString; xRE: TRichEdit; begin with xExport.AddWorkSheet('Rich text') do begin AddRow.AddCellString(Title).SetFontSize(20); AddRow; AddRow.AddCellString('The following text was loaded from an external RTF file.'+sLineBreak+ 'You find the file in "doc\text.rtf".').SetCalculateRowHeight(erhMultiLine); AddRow; AddRow; xRE := TRichEdit.Create(nil); try xRE.Visible := False; xRE.Parent := Self; xRE.Lines.LoadFromFile(docDir+'text.rtf'); xCell := AddRow.AddCellString; {$IF (CompilerVersion >= 18.0)} //DELPHI 2006 and newer xCell.LoadRichTextFromEditor(xRE); {$ELSE} //DELPHI 7 RichEditToStringCell(xRE, xCell); {$IFEND} xCell.SetWrapText.SetWidth(400).SetHeight(150); finally xRE.Free; end; end; end;Create a cell with rich text formatting from code:
procedure AddWorkSheet_CellTypes(xExport: TOExport); begin with xExport.AddWorkSheet('Cell types') do begin AddRow.AddCellString(Title).SetFontSize(20); AddRow; with AddRow do begin AddCellString('Rich text'); AddCellString. AppendFormattedText('Rich text ', 0, clRed, 'Courier New'). AppendFormattedText('example ', 0, clNone, 'Times New Roman', efsYes). AppendFormattedText('- '). AppendFormattedText('nice and easy!', 0, clNavy, '', efsAuto, efuDouble); end; with AddRow do begin AddCellString('Mass–energy equivalence'); AddCellString. AppendFormattedTextFontStyle('E', efsAuto, efuAuto, efsYes). AppendFormattedText(' = '). AppendFormattedTextFontStyle('mc', efsAuto, efuAuto, efsYes). AppendFormattedTextFontStyle('2', efsAuto, efuAuto, efsAuto, efsAuto, efeSuperscript); end; end; end;