NameCollection Class
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Server
- Assembly
TXTextControl.TXSheetControl. Api. dll
- Install
dotnet add package TXTextControl..NET 10 and later.TXSheetControl. Server
- Also in
TXTextControl.asTXSheetControl. Blazor TXTextControl.TXSheetControl. Api. dll
- Inherits
- Document
Object - Name
Collection
- Document
Case-insensitive workbook or worksheet names; every operation uses the same scope as the JS collection.
Syntax
public class NameCollection
Members
Methods
| Method | Description |
|---|---|
| GetAsync | Looks up a name in this explicit scope; unknown names raise a document error. |
| ListAsync | Reads detached definitions in this collection's scope. |
| RemoveAsync | Removes a definition in this scope; formulas subsequently report an unresolved name. |
| SetAsync | Creates or replaces a formula/reference definition in this scope, as one undoable transaction. |
Examples
Build a small report using this document API and return its PDF bytes. Pass a live control with a fresh workbook; the caller owns its lifetime.
using TXTextControl.TXSheetControl.Server;
async Task<byte[]> CreateNameCollectionReportAsync(ServerSheetControl control)
{
var book = control.Workbook;
var sheet = await book.Sheets.AtAsync(0);
await sheet.Cell("B8").SetValueAsync(120);
await sheet.Cell("B9").SetValueAsync(80);
await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");
var nameCollection = book.Names;
await nameCollection.SetAsync("InvoiceTotal", "='" + (await sheet.GetNameAsync()).Replace("'", "''") + "'!$B$10");
await sheet.Cell("D10").SetFormulaAsync("=InvoiceTotal");
return await control.SaveAsync(StreamType.PDF);
}