DrawingCollection Class
Public class for DrawingCollection.
Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.
ES module import: import { DrawingCollection } from '@txtextcontrol/tx-sheet-control';.
Constructor
new DrawingCollection(sheet: Worksheet): DrawingCollection
| Parameter | Type | Optional | Description |
|---|---|---|---|
sheet | Worksheet | No | Value matching sheet's declared type and the owning object's validation rules. |
Returns: DrawingCollection.
Members
Properties
| Property | Description |
|---|---|
| count | The count value of DrawingCollection. |
| sheet | The sheet value of DrawingCollection. |
Methods
| Method | Description |
|---|---|
| addPicture | Insert an embedded picture above cells. |
| addShape | Insert a shape with friendly preset/anchor/size options. |
| align | Align selected objects/groups against each other. |
| at | Find by zero-based z-order index. |
| get | Find by exact drawing name; throw when absent or ambiguous. |
| getById | Find by drawing identity. |
| group | Group drawings in the same sheet. |
| remove | Remove a drawing handle or ID, including its group if applicable. |
Examples
Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.
import type { Workbook } from '@txtextcontrol/tx-sheet-control';
function createDrawingCollectionReport(book: Workbook) {
const sheet = book.sheets.at(0);
sheet.cell('A1').setText('October invoice');
sheet
.cell('A1')
.format({
fontFamily: 'Liberation Sans',
fontSize: 16,
bold: true,
textColor: '#ffffff',
fillColor: '#163b63',
});
sheet.columns.at(0).setWidth({ pixels: 240 });
sheet.range('B8:B9').setValues([[120], [80]]);
sheet.cell('B10').setFormula('=SUM(B8:B9)');
sheet.range('B8:B10').format({ numberFormatCode: '#,##0.00', fontSize: 11 });
sheet.drawings.addShape({
type: 'rectangle',
text: 'Approved',
anchor: { cell: 'F2' },
size: { width: 180, height: 60 },
fill: '#e5eef4',
});
return sheet;
}
See Also
addBarcode — Inserts a movable barcode or QR code. Missing source/value reads its anchor cell.