TX Sheet Control

.NET API Names

Topic

The class names of the TX Sheet Control .NET API are short. The package name and the namespace already identify server processing, so the document API uses concise names such as Workbook, Worksheet, TableCollection, Cell and Range.

Read on for the processing entry point, the classes you use for document work, the naming of asynchronous methods and the difference between the spreadsheet Range and System.Range.

How the Names Are Chosen

  • The entry point. The .NET processing entry point is ServerSheetControl in the namespace TXTextControl.TXSheetControl.Server.
  • The Async suffix. The Async suffix of a method name identifies an asynchronous operation. Await these operations.
  • No aliases. There are no legacy API aliases.

Process a Workbook

The following code writes two amounts and their sum into the first worksheet and saves the workbook as invoice.pdf:

using TXTextControl.TXSheetControl.Server;

await using var control = new ServerSheetControl();
Workbook book = control.Workbook;
Worksheet sheet = await book.Sheets.AtAsync(0);
Cell amount = sheet.Cell("B8");
await amount.SetValueAsync(120);
await sheet.Cell("B9").SetValueAsync(80);
await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");
await control.SaveAsync("invoice.pdf", StreamType.PDF);

The code works as follows:

Which Classes You Work With

Use Workbook, Worksheet, Cell, Range and their owned collections for document work:

ClassPurpose
WorkbookAsynchronous workbook editing, formatting, calculation, loading and saving
WorksheetA handle bound to a worksheet ID and an opaque document generation
CellA worksheet-bound cell handle that separates literal text, formulas, values, formatting and pictures
RangeA worksheet-bound rectangular range for atomic reads, writes, formatting and copy operations
TableCollectionThe Excel tables of a worksheet, with workbook-unique names and stable identities
DocumentObjectThe base for sheet-bound handles. Its methods perform asynchronous I/O; creating a cell or range handle performs none

ServerSheetControlOptions, the document limits, locale and font settings for server spreadsheet operations, and ServerSheetControlException describe the processing entry point.

Distinguish Range From System.Range

The spreadsheet Range class and System.Range are different types. Prefer var when you obtain worksheet ranges, or add an alias when you declare the type explicitly:

using Range = TXTextControl.TXSheetControl.Server.Range;
using TXTextControl.TXSheetControl.Server;

async Task SetAmountsAsync(Worksheet sheet)
{
    Range amounts = sheet.Range("B8:B9");
    await amounts.SetValuesAsync(new object?[][] { [120], [80] });
}

The code works as follows:

  • The alias using Range = TXTextControl.TXSheetControl.Server.Range; makes Range name the spreadsheet class, not System.Range.
  • Worksheet.Range returns a handle for the range B8:B9.
  • Range.SetValuesAsync writes 120 into B8 and 80 into B9.

What the Reference Describes

All signatures, examples and routes of the reference describe the current TX Sheet Control packages. Earlier product namespaces, package names and reference routes are not supported.

Next Steps

  • .NET: install the Server package and process a first workbook in .NET.
  • Workbooks and Worksheets: workbook ownership, worksheet handles and document replacement.
  • Tables: Excel-style tables with named columns and calculated columns.
  • .NET API: the namespaces, classes and members of the .NET API.