[]
• new ReportSheet(name)
表示 ReportSheet。
example
const spread = new GC.Spread.Sheets.Workbook('spread-host', { sheetCount: 0 });
const reportSheet = spread.addSheetTab(0, 'orders-report', GC.Spread.Sheets.SheetType.reportSheet);
const templateSheet = reportSheet.getTemplate();
const ordersTable = spread.dataManager().addTable('Orders', {
remote: {
read: {
url: 'https://demodata.grapecity.com/northwind/api/v1/Orders'
}
}
});
// 从远程加载数据。
ordersTable.fetch().then(() => {
// 设置模板样式。
const headerStyle = new GC.Spread.Sheets.Style();
headerStyle.backColor = '#80CBC4';
headerStyle.foreColor = '#424242';
headerStyle.hAlign = GC.Spread.Sheets.HorizontalAlign.right;
headerStyle.font = '12px Maine';
const dataStyle = new GC.Spread.Sheets.Style();
dataStyle.foreColor = '#424242';
dataStyle.hAlign = GC.Spread.Sheets.HorizontalAlign.right;
dataStyle.font = '12px Maine';
const border = new GC.Spread.Sheets.LineBorder('#E0E0E0', 1);
dataStyle.borderBottom = border;
dataStyle.borderTop = border;
dataStyle.borderLeft = border;
dataStyle.borderRight = border;
const colWidthArray = [90, 90, 90, 80, 220, 150, 110];
colWidthArray.forEach((width, i) => {
templateSheet.setColumnWidth(i, width);
});
templateSheet.getRange('A1:G1').setStyle(headerStyle);
templateSheet.getRange('A2:G2').setStyle(dataStyle);
templateSheet.setFormatter(1, 2, 'yyyy-MM-dd');
// 设置模板的值和绑定。
const columns = ['orderId', 'customerId', 'orderDate', 'freight', 'shipName', 'shipCity', 'shipCountry'];
columns.forEach((columnName, i) => {
templateSheet.setValue(0, i, `${columnName[0].toUpperCase()}${columnName.substring(1)}`);
templateSheet.setTemplateCell(1, i, {
type: 'List',
binding: `Orders[${columnName}]`,
});
});
reportSheet.refresh();
});
| Name | Type | Description |
|---|---|---|
name |
string |
ReportSheet的名称。 |
• options: IReportOptions
表示 ReportSheet 的选项。
property [dirtyStyle] 在预览模式下用于绘制修改单元格的样式。
property [printAllPages] 是否打印所有页面。
property [showHiddenRowCol] 指示是否显示隐藏的行或列。
property [hiddenRowColStyle] 此样式将在显示隐藏的行和列时用于设置标题样式。
▸ addRecordAt(row, col): void
根据指定单元格添加记录。
example
// 在 A2 单元格添加记录。
reportSheet.addRecordAt(1, 0);
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
void
▸ bind(type, data?, fn?): void
将事件绑定到报告表。
example
// 此示例将 ReportSheetDataChanged 事件绑定到报告表。
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.setTemplateCell(0, 1, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.setDataEntrySetting([ {
name: "Write Back Rule 1",
tableName: "Orders",
fields: [
{ dbColumnName: "orderId", formula: "A1", isPrimary: true },
{ dbColumnName: "customerId", formula: "B1" },
],
includeUnmodified: false,
skipRecordWithEmptyValue: false
} ]);
report.renderMode("Preview");
report.bind(GC.Spread.Sheets.Events.ReportSheetDataChanged, (event, args) => {
let reportsheet = args.sheet, changes = reportsheet.getChanges();
if (allowSubmit(changes)) { // users can submit or drop this changing.
reportsheet.submit(); // submit changes.
} else {
reportsheet.refresh(); // drop changes.
}
});
// 在 UI 中编辑/更新/删除记录后,将触发 ReportSheetDataChanged 事件。
| Name | Type | Description |
|---|---|---|
type |
string |
事件类型。 |
data? |
any |
可选。指定要传递给函数的附加数据。 |
fn? |
Function |
指定在事件发生时运行的函数。 |
void
▸ currentPage(page?): number
获取或设置当前页面索引。
example
// 获取当前页面索引。
const page = reportSheet.currentPage();
// 转到下一页。
reportSheet.currentPage(page + 1);
| Name | Type | Description |
|---|---|---|
page? |
number |
页面索引(0 基)。 |
number
返回当前页面索引。
▸ deleteRecordAt(row, col): void
根据指定单元格删除记录。
example
// 删除 A2 单元格的记录。
reportSheet.deleteRecordAt(1, 0);
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
void
▸ generatePageSheets(addToSpread, sheetNameGenerator?): Worksheet[]
将当前报告的每个页面生成一个工作表,并返回它们组成的数组。
example
// 生成页面并添加到工作表。
const pageSheets = reportSheet.generatePageSheets(true);
// 生成页面并添加到工作表,并自定义工作表名称。
const pageSheets = reportSheet.generatePageSheets(true, (i) => `report-page-${i + 1}`);
| Name | Type | Description |
|---|---|---|
addToSpread |
boolean |
控制是否将页面工作表添加到当前工作表。 |
sheetNameGenerator? |
SheetNameGenerator |
可选的工作表名称生成器。 |
返回生成的页面工作表。
▸ getActualStyle(row, col): Style
获取当前渲染模式下的单元格实际样式。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.getCell(0, 0).backColor("red");
templateSheet.setTemplateCell(1, 0, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.getCell(1, 0).backColor("green");
const designActualStyle1 = report.getActualStyle(0, 0); // backColor: red
const designActualStyle2 = report.getActualStyle(1, 0); // backColor: green
report.renderMode("Preview");
const previewActualStyle1 = report.getActualStyle(0, 0); // backColor: red
const previewActualStyle2 = report.getActualStyle(1, 0); // backColor: red
report.renderMode("PaginatedPreview");
const paginatedPreviewActualStyle1 = report.getActualStyle(0, 0); // backColor: red
const paginatedPreviewActualStyle2 = report.getActualStyle(1, 0); // backColor: red
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
返回当前渲染模式下的单元格实际样式。
▸ getCells(templateRow, templateCol, currentRow?, currentCol?): IDataCell[]
获取当前单元格在预览模式下的展开单元格。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.setTemplateCell(1, 0, {
binding: "Orders[orderId]",
type: "Group",
});
report.regenerateReport();
const allCustomerIdCells = report.getCells(0, 0); // all 89 cells
const fistCustomerIdCell = report.getCells(0, 0, 0, 0); // value: VINET
const allOrderIdCells = report.getCells(1, 0); // all 830 cells
const firstOrderIdCell = report.getCells(1, 0, 89, 0); // value: 10248
| Name | Type | Description |
|---|---|---|
templateRow |
number |
模板中的行索引。 |
templateCol |
number |
模板中的列索引。 |
currentRow? |
number |
当前单元格在预览中的行索引。 |
currentCol? |
number |
当前单元格在预览中的列索引。 |
返回当前单元格在预览模式下的展开单元格。
▸ getChanges(): Change[]
返回报告表数据条目模式更新插入和删除数据更改。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
showCollapseButton: true
});
templateSheet.setTemplateCell(0, 1, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.setDataEntrySetting([ {
name: "Write Back Rule 1",
tableName: "Orders",
fields: [
{ dbColumnName: "orderId", formula: "A1", isPrimary: true },
{ dbColumnName: "customerId", formula: "B1" },
],
includeUnmodified: false,
skipRecordWithEmptyValue: false
} ]);
report.renderMode("Preview");
report.updateCellValue(0, 1, "test");
report.addRecordAt(1, 0);
report.updateCellValue(2, 0, 111);
report.updateCellValue(2, 1, "test2");
report.deleteRecordAt(3, 0);
report.getChanges(); // 一个删除记录和两个更新记录。
Change[]
返回报告表更新插入和删除数据更改。
▸ getCollapseState(row, col): boolean
返回指定单元格的折叠状态。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
showCollapseButton: true
});
templateSheet.setTemplateCell(0, 1, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.addSpan(0, 0, 2, 1);
report.renderMode("Preview");
report.getCollapseState(0, 0); // false
report.toggleCollapseState(0, 0);
report.getCollapseState(0, 0); // true
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
boolean
▸ getColumnWidth(col): number
获取指定列的列宽。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
spillDirection: "Horizontal"
});
templateSheet.setColumnWidth(0, 100);
const designColumnWidth1 = report.getColumnWidth(0); // ColumnWidth: 100
const designColumnWidth2 = report.getColumnWidth(1); // ColumnWidth: 62
report.renderMode("Preview");
const previewColumnWidth1 = report.getColumnWidth(0); // ColumnWidth: 100
const previewColumnWidth2 = report.getColumnWidth(1); // ColumnWidth: 100
report.renderMode("PaginatedPreview");
const paginatedPreviewColumnWidth1 = report.getColumnWidth(0); // ColumnWidth: 100
const paginatedPreviewColumnWidth2 = report.getColumnWidth(1); // ColumnWidth: 100
| Name | Type | Description |
|---|---|---|
col |
number |
列索引。 |
number
返回列宽。
▸ getPageCount(): number
获取报表中的页数。
example
const pageCount = reportSheet.getPageCount();
number
返回报表中的页数。
▸ getPagesCount(): number
获取报告的页面数量。
deprecated 从19.0.0版本开始,请改用“getPageCount”
example
// 获取页面数量。
const pagesCount = reportSheet.getPagesCount();
number
返回报告的页面数量。
▸ getRange(): Range
返回报告表范围。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(199, 0, {
binding: "Orders[customerId]",
type: "Group",
});
const designRange = report.getRange(); // row: 0, col: 0, rowCount: 200, colCount: 20.
report.renderMode("Preview");
const previewRange = report.getRange(); // row: 0, col: 0, rowCount: 288, colCount: 1.
report.renderMode("PaginatedPreview");
const paginatedPreviewRange = report.getRange(); // row: 0, col: 0, rowCount: 45, colCount: 1.
返回报告表范围。 如果渲染模式为设计,返回模板表范围。 如果渲染模式为预览,返回整个报告范围。 如果渲染模式为分页预览,返回当前页的范围。
▸ getRowHeight(row): number
获取指定行的高度。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.setRowHeight(0, 30);
const designRowHeight1 = report.getRowHeight(0); // RowHeight: 30
const designRowHeight2 = report.getRowHeight(1); // RowHeight: 20
report.renderMode("Preview");
const previewRowHeight1 = report.getRowHeight(0); // RowHeight: 30
const previewRowHeight2 = report.getRowHeight(1); // RowHeight: 30
report.renderMode("PaginatedPreview");
const paginatedPreviewRowHeight1 = report.getRowHeight(0); // RowHeight: 30
const paginatedPreviewRowHeight2 = report.getRowHeight(1); // RowHeight: 30
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
number
返回行高。
▸ getSpan(row, col): Range
获取当前渲染模式下的单元格范围。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.addSpan(0, 0, 2, 1);
const designSpan1 = report.getSpan(0, 0); // span: row: 0, col: 0, rowCount: 2, colCount: 1
const designSpan2 = report.getSpan(2, 0); // span: null
report.renderMode("Preview");
const previewSpan1 = report.getSpan(0, 0); // span: row: 0, col: 0, rowCount: 2, colCount: 1
const previewSpan2 = report.getSpan(2, 0); // span: row: 2, col: 0, rowCount: 2, colCount: 1
report.renderMode("PaginatedPreview");
const paginatedPreviewSpan1 = report.getSpan(0, 0); // span: row: 0, col: 0, rowCount: 2, colCount: 1
const paginatedPreviewSpan2 = report.getSpan(2, 0); // span: row: 2, col: 0, rowCount: 2, colCount: 1
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
返回单元格的范围。
▸ getStyle(row, col): Style
获取当前渲染模式下的单元格样式。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.getCell(0, 0).backColor("red");
templateSheet.setTemplateCell(1, 0, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.getCell(1, 0).backColor("green");
const designStyle1 = report.getStyle(0, 0); // backColor: red
const designStyle2 = report.getStyle(1, 0); // backColor: green
report.renderMode("Preview");
const previewStyle1 = report.getStyle(0, 0); // backColor: red
const previewStyle2 = report.getStyle(1, 0); // backColor: red
report.renderMode("PaginatedPreview");
const paginatedPreviewStyle1 = report.getStyle(0, 0); // backColor: red
const paginatedPreviewStyle2 = report.getStyle(1, 0); // backColor: red
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
返回单元格的样式。
▸ getTemplate(): TemplateSheet
获取当前报告表的模板表。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate(); // 获取报告表的模板表
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
report.renderMode("Preview");
返回当前报告表的模板表。
▸ getTemplateCell(row, col): TemplateCell
获取指定单元格的模板单元格。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.setTemplateCell(1, 0, {
binding: "Orders[orderId]",
type: "Group",
});
const designTemplateCell1 = report.getTemplateCell(0, 0); // binding: Orders[customerId]
const designTemplateCell2 = report.getTemplateCell(1, 0); // binding: Orders[orderId]
report.renderMode("Preview");
const previewTemplateCell1 = report.getTemplateCell(0, 0); // binding: Orders[customerId]
const previewTemplateCell2 = report.getTemplateCell(1, 0); // binding: Orders[customerId]
const previewTemplateCell3 = report.getTemplateCell(89, 0); // binding: Orders[orderId]
report.renderMode("PaginatedPreview");
const paginatedPreviewTemplateCell1 = report.getTemplateCell(0, 0); // binding: Orders[customerId]
const paginatedPreviewTemplateCell2 = report.getTemplateCell(1, 0); // binding: Orders[customerId]
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
返回指定单元格的模板单元格。 如果渲染模式为设计,返回指定单元格的模板单元格。 如果渲染模式为预览,返回指定单元格的模板单元格。 如果渲染模式为分页预览,返回指定单元格的模板单元格。
▸ getValue(row, col): any
获取当前渲染模式下的单元格值。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.setValue(1, 0, "test");
const designValue = report.getValue(1, 0); // test
report.renderMode("Preview");
const previewValue = report.getValue(1, 0); // TOMSP
report.renderMode("PaginatedPreview");
const paginatedPreviewValue = report.getValue(1, 0); // TOMSP
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
any
返回单元格的值。
▸ isDirty(): boolean
返回一个布尔值,指示报告是否具有未提交的更改。
example
// 如果当前报告表具有未提交的更改,isDirty 将为 true.
const isDirty = reportSheet.isDirty();
boolean
如果报告具有未提交的更改,则返回 true,否则返回 false.
▸ loadTemplate(templateJson): void
更新报告表模板,报告也将根据新模板和参数值重新生成。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
const templateSheet = new GC.Spread.Report.TemplateSheet("Template");
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
report.loadTemplate(templateSheet.toJSON());
| Name | Type | Description |
|---|---|---|
templateJson |
Object |
模板 json。 |
void
▸ name(value?): any
获取或设置报告表的名称。
example
// 获取报告表的名称
const name = reportSheet.name();
// 设置报告表的名称
reportSheet.name('new-name');
| Name | Type | Description |
|---|---|---|
value? |
string |
报告表的名称。 |
any
返回报告表的名称。
▸ parameter(parameter?): IParameter
获取或设置报告表的参数。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
report.getTemplate().setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
filter: {
condition: {
column: "customerId",
operator: "Equal",
parameter: "customerId"
}
}
});
report.renderMode("Preview");
let parameter = report.parameter(); // 获取报告表的参数
parameter.customerId = "VINET";
report.parameter(parameter); // 设置参数。
report.regenerateReport(); // 根据新参数重新生成报告表。
| Name | Type | Description |
|---|---|---|
parameter? |
IParameter |
设置新的参数进入报告表。 |
返回报告表当前工作参数。
▸ printInfo(value?): ReportSheet | PrintInfo
获取或设置报告表的打印信息。
example
// 设置纸张大小。
const printInfo = reportSheet.printInfo();
printInfo.paperSize(new GC.Spread.Sheets.Print.PaperSize(GC.Spread.Sheets.Print.PaperKind.a3));
| Name | Type | Description |
|---|---|---|
value? |
PrintInfo |
报告表的打印信息。 |
如果未设置值,则返回报告表的打印信息;否则,返回报告表。
▸ printPageIndexes(pageIndexes?): number[]
获取或设置要打印的页面索引数组。空数组表示打印所有页面。
example
// 打印当前报告的第一个和第五个页面。
reportSheet.printPageIndexes([0, 4]);
reportSheet.options.printAllPages = true;
spread.print();
// 清除打印页面索引设置。
reportSheet.printPageIndexes([]);
| Name | Type | Description |
|---|---|---|
pageIndexes? |
number[] |
要打印的页面索引数组(0 基)。 |
number[]
返回要打印的页面索引数组。
▸ refresh(): void
刷新当前报告表,所有渲染模式都支持此功能。 设计:刷新模板表的缓存并重新绘制。 预览:根据当前模板表重新生成报告并重新绘制。 分页预览:根据当前模板表重新生成报告并重新绘制。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
report.refresh();
void
▸ regenerateReport(): void
根据当前模板重新生成报告。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
report.regenerateReport();
void
▸ renderMode(renderMode?): RenderMode
获取或设置渲染模式。
example
// 切换到设计模式。
reportSheet.renderMode('Design');
// 切换到预览模式。
reportSheet.renderMode('Preview');
// 切换到分页预览模式。
reportSheet.renderMode('PaginatedPreview');
| Name | Type | Description |
|---|---|---|
renderMode? |
RenderMode |
渲染模式。 |
返回渲染模式。
▸ repaint(): void
重新绘制当前报告表。
void
▸ resetCellValue(row, col): void
重置指定单元格的值。
example
// 如果 A2 单元格的值被修改,resetCellValue 可以重置 A2 单元格到其原始值。
reportSheet.resetCellValue(1, 0);
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
void
▸ setParametersUI(host, initParametersUI, onChange): void
设置报告表的参数UI。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
report.parameter({ customerId: "VINET" });
report.getTemplate().setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
filter: {
condition: {
column: "customerId",
operator: "Equal",
parameter: "customerId"
}
}
});
report.renderMode("Preview");
const host = document.getElementById("parameterUIHost");
report.setParametersUI(host, initParametersUI, onChanged);
function initParametersUI (sheet) {
sheet.getCell(3, 3).value("CustomerId:"); // 添加静态标签单元格
sheet.getCell(3, 4).bindingPath("customerId").tag("customerId"); // 添加参数绑定路径和标签到此单元格
const submitButton = new GC.Spread.Sheets.CellTypes.Button(); // 添加提交按钮
submitButton.text("Submit");
sheet.getCell(3, 5).cellType(submitButton).tag("submitButton"); // 设置按钮单元格类型和标签到此单元格
}
function onChanged (reportSheet, changedArgs) {
if (changedArgs.tag === "submitButton") { // 提交按钮点击。
reportSheet.regenerateReport();
}
if (changedArgs.tag === "customerId") {
changedArgs.newValue = changedArgs.newValue.toUpperCase(); // 更新 newValue 这里。
}
}
| Name | Type | Description |
|---|---|---|
host |
string | HTMLElement |
参数UI宿主元素或宿主ID。 |
initParametersUI |
InitParametersUIFunctionType |
修改参数UI表的回调。 |
onChange |
OnChangeFunctionType |
参数UI值更改或按钮点击时的回调。 |
void
▸ submit(): void
通过 DataManger 提交更改到远程数据库。
example
// 提交更改。
reportSheet.submit();
void
▸ toWorksheet(): Worksheet
根据当前报告表生成一个静态工作表(没有公式,没有单元格绑定)。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
});
report.renderMode("Preview");
const reportWorksheet = report.toWorksheet();
返回生成的工作表。
▸ toggleCollapseState(row, col, targetState?, recursive?): void
切换指定单元格的折叠状态。
example
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[customerId]",
type: "Group",
showCollapseButton: true
});
templateSheet.setTemplateCell(0, 1, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.addSpan(0, 0, 2, 1);
report.renderMode("Preview");
report.toggleCollapseState(0, 0);
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
targetState? |
"Expanded" | "Collapsed" |
目标状态,折叠或展开特定单元格。 |
recursive? |
boolean |
如果为 true,将更新当前单元格及其所有后代单元格的状态,如果为 false,则只更新当前单元格。 |
void
▸ unbind(type, fn?): void
移除报告表的事件绑定。
example
// 此示例在第一次数据更改后取消绑定 ReportSheetDataChanged 事件。
const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate();
templateSheet.setTemplateCell(0, 0, {
binding: "Orders[orderId]",
type: "Group",
});
templateSheet.setTemplateCell(0, 1, {
binding: "Orders[customerId]",
type: "Group",
});
templateSheet.setDataEntrySetting([ {
name: "Write Back Rule 1",
tableName: "Orders",
fields: [
{ dbColumnName: "orderId", formula: "A1", isPrimary: true },
{ dbColumnName: "customerId", formula: "B1" },
],
includeUnmodified: false,
skipRecordWithEmptyValue: false
} ]);
report.renderMode("Preview");
report.bind(GC.Spread.Sheets.Events.ReportSheetDataChanged, (event, args) => {
let reportsheet = args.sheet, changes = reportsheet.getChanges();
console.log(changes);
reportsheet.unbind(GC.Spread.Sheets.Events.ReportSheetDataChanged);
});
// 在 UI 中编辑/更新/删除记录后,将触发 ReportSheetDataChanged 事件。
| Name | Type | Description |
|---|---|---|
type |
string |
事件类型。 |
fn? |
Function |
指定要移除绑定的函数。 |
void
▸ updateCellValue(row, col, value): void
更新指定单元格的值。
example
// 更新 A2 单元格的值。
reportSheet.updateCellValue(1, 0, 'test');
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
col |
number |
列索引。 |
value |
any |
单元格的新值。 |
void