TX Sheet Control

WorkbookBatch.FormatText Method

Method
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Api.dll from the private NuGet feed or the supplied NuGet folder
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll

Creates or updates a document-bound handle or queued operation; the owning workbook retains validation authority.

Syntax

public void FormatText(Cell cell, int start, int length, CellTextStyle style)

Parameters

ParameterTypeOptionalDescription
cellCellNoOperation-specific input; see this type's units and ownership contract.
startintNoZero-based UTF-16 start offset.
lengthintNoUTF-16 span length; surrogate pairs must remain whole.
styleCellTextStyleNoFont overrides for the selected characters.

Return Value

void.

Examples

Create a working document workflow using WorkbookBatch. Return the generated document or application data to the caller.

using TXTextControl.TXSheetControl.Server;

async Task<byte[]> BuildWorkbookBatchFormatTextAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var title = sheet.Cell("A1");
    await book.BatchAsync(batch =>
    {
        batch.SetText(title, "October invoice");
        batch.Format(title, new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
        batch.SetValues(sheet.Range("B8:B9"), [[120], [80]]);
        batch.SetFormula(sheet.Cell("B10"), "=SUM(B8:B9)");
        batch.Format(sheet.Range("B8:B10"), new { numberFormatCode = "#,##0.00", fontFamily = "Liberation Sans", fontSize = 11 });
        batch.FormatText(title, 0, 7, new CellTextStyle(Bold: true));
    });

    return await control.SaveAsync(StreamType.PDF);
}

Remarks

Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.

See Also