TX Sheet Control

DataSnapshot Constructor

Constructor
Namespace
TXTextControl.TXSheetControl.Data
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Data.dll from the private NuGet feed or the supplied NuGet folder

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

Syntax

public DataSnapshot(IEnumerable<string> columns, IEnumerable<IEnumerable<object?>> rows)

Parameters

ParameterTypeOptionalDescription
columnsIEnumerable<string>NoValue matching columns's declared type and the owning object's validation rules.
rowsIEnumerable<IEnumerable<object?>>NoValue matching rows's declared type and the owning object's validation rules.

Return Value

DataSnapshot.

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[]> BuildDataSnapshotConstructorAsync(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);
}

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