TX Sheet Control

DataSnapshot Class

Class
Namespace
TXTextControl.TXSheetControl.Data
Package
TXTextControl.TXSheetControl.Server from the private NuGet feed or the supplied NuGet folder
Assembly
TXTextControl.TXSheetControl.Data.dll
Install
dotnet add package TXTextControl.TXSheetControl.Server .NET 10 and later.

Immutable detached schema and rows, serializable as a browser data response. At most 256 columns / 250,000 cells.

Syntax

public class DataSnapshot

Members

Constructors

ConstructorDescription
ConstructorValidates and detaches all input. Rejects nested values, duplicate headers, nonfinite or unsafe integers.

Properties

PropertyDescription
ColumnsStable unique field names, in the same order as row cells.
RowsImmutable rectangular rows of string, double, boolean or null values. Dates use ISO strings.

Examples

Create a working report from bounded HTTP sales data. Supply an application-owned HttpClient and service URL; scope cached data to its actual audience.

using TXTextControl.TXSheetControl.Data;
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> BuildDataSnapshotExampleAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var data = new DataSnapshot(["Region", "Revenue"], [["North", 42000], ["South", 38500]]);
    await sheet.Range("A1:B1").SetValuesAsync([data.Columns.Cast<object?>().ToArray()]);
    await sheet.Range("A2:B3").SetValuesAsync(data.Rows.Select(row => row.ToArray()).ToArray());
    await sheet.Tables.AddAsync("RegionalSales", "A1:B3", new TableOptions { Style = "TableStyleMedium2", ShowRowStripes = true });
    return await control.SaveAsync(StreamType.PDF);
}

See Also