[]
        
(Showing Draft Content)

GC.Spread.Report.ReportSheet

类: ReportSheet

Spread.Report.ReportSheet

Table of contents

构造方法

属性

方法

构造方法

constructor

new ReportSheet(name)

报表表单

代码示例

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.mescius.io/northwind/api/v1/orders'
        }
    }
});

// load the data from remote.
ordersTable.fetch().then(() => {
    // set style for the template.
    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');

    // set value and binding for the template.
    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 string 报表表单名称

属性

options

options: IReportOptions

报表表单的选项

property [dirtyStyle] 该样式将在预览模式下用于绘制修改后的单元格

property [printAllPages] 是否打印所有页面

方法

addRecordAt

addRecordAt(row, col): void

根据指定的单元格添加记录

代码示例

// add record at A2 cell.
reportSheet.addRecordAt(1, 0);

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

void


bind

bind(type, data?, fn?): void

Binds an event to the report sheet.

代码示例

//This example bind the ReportSheetDataChanged event into report sheet.
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.
    }
});
// after reportsheet edit / update / delete records in UI will trigger ReportSheetDataChanged event.

参数

属性名 类型 说明
type string 事件类型
data? any 可选的,指定要传递给函数的附加数据
fn? Function 指定事件发生时要运行的函数

返回值

void


currentPage

currentPage(page?): number

获取或设置当前页面索引

代码示例

// get the current page index.
const page = reportSheet.currentPage();

// go to the next page.
reportSheet.currentPage(page + 1);

参数

属性名 类型 说明
page? number 页面索引(0 为基础)

返回值

number

返回当前页面索引


deleteRecordAt

deleteRecordAt(row, col): void

基于指定的单元格删除记录

代码示例

// delete record at A2 cell.
reportSheet.deleteRecordAt(1, 0);

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

void


generatePageSheets

generatePageSheets(addToSpread, sheetNameGenerator?): Worksheet[]

将当前报告的每个页面作为工作表生成,并将其返回数组

代码示例

// generate the pages and add them to the spread.
const pageSheets = reportSheet.generatePageSheets(true);

// generate the pages and add them to the spread, and customize the sheet name.
const pageSheets = reportSheet.generatePageSheets(true, (i) => `report-page-${i + 1}`);

参数

属性名 类型 说明
addToSpread boolean 是否添加工作表到当前 Spread
sheetNameGenerator? SheetNameGenerator 可选的工作表名称生成器

返回值

Worksheet[]

返回生成的工作表


getActualStyle

getActualStyle(row, col): Style

在当前渲染模式下获取单元格的实际样式

代码示例

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

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

Style

返回单元格的实际样式


getCells

getCells(templateRow, templateCol, currentRow?, currentCol?): IDataCell[]

在预览中获取基于当前单元格的扩展单元格

代码示例

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

参数

属性名 类型 说明
templateRow number 报表模板的行索引
templateCol number 报表模板的列索引
currentRow? number 预览模式下的当前行索引
currentCol? number 预览模式下的当前列索引

返回值

IDataCell[]

返回基于当前单元格的扩展单元格


getChanges

getChanges(): Change[]

返回报表表数据录入方式更新插入和删除数据变化

代码示例

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(); // one delete record and two update records.

返回值

Change[]

返回报表表更新插入和删除数据更改


getCollapseState

getCollapseState(row, col): boolean

返回特定单元格的折叠状态

代码示例

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

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

boolean


getColumnWidth

getColumnWidth(col): number

根据列索引获取列宽

代码示例

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

参数

属性名 类型 说明
col number 列索引

返回值

number

列宽


getPagesCount

getPagesCount(): number

获取报表页数

代码示例

// get the pages count.
const pagesCount = reportSheet.getPagesCount();

返回值

number

报表页数


getRange

getRange(): Range

代码示例

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.

返回值

Range

返回报告范围 如果渲染模式是设计,返回模板表范围 如果渲染模式是预览,返回整个报告范围 如果渲染模式为分页预览,返回当前页面的范围


getRowHeight

getRowHeight(row): number

根据行索引返回行高

代码示例

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

参数

属性名 类型 说明
row number 行索引

返回值

number

行高


getSpan

getSpan(row, col): Range

在当前渲染模式下获取单元格的范围

代码示例

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

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

Range

单元格范围


getStyle

getStyle(row, col): Style

在当前渲染模式下获取单元格的样式

代码示例

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

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

Style

单元格样式


getTemplate

getTemplate(): TemplateSheet

获取当前报告表的模板

代码示例

const report = spread.addSheetTab(0, "Report", GC.Spread.Sheets.SheetType.reportSheet);
report.renderMode("Design");
const templateSheet = report.getTemplate(); // get the reportSheet templateSheet
templateSheet.setTemplateCell(0, 0, {
   binding: "Orders[customerId]",
   type: "Group",
});
report.renderMode("Preview");

返回值

TemplateSheet

当前报表的模板


getTemplateCell

getTemplateCell(row, col): TemplateCell

获取指定单元格的模板单元格

代码示例

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]

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

TemplateCell

返回指定单元格的模板单元格 如果渲染模式是设计,返回指定的行col中模板表的模板单元格 如果渲染模式是预览,返回指定单元格的模板单元格 如果渲染模式为分页预览,返回指定单元格的模板单元格


getValue

getValue(row, col): any

在当前渲染模式下获取单元格的值

代码示例

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

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

any

单元格值


isDirty

isDirty(): boolean

返回布尔值表示报告是否具有未提交的变化

代码示例

// if the current reportSheet has un-submit changes, isDirty will be true.
const isDirty = reportSheet.isDirty();

返回值

boolean

如果报告有未提交的更改,则返回true,否则返回false


loadTemplate

loadTemplate(templateJson): void

更新报告表模板,将根据新的模板和参数值重新生成报告

代码示例

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());

参数

属性名 类型 说明
templateJson Object 模板 JSON

返回值

void


name

name(value?): any

获取或设置报告表单的名称

代码示例

// get the report sheet name
const name = reportSheet.name();

// set the report sheet name
reportSheet.name('new-name');

参数

属性名 类型
value? string

返回值

any

报告表单的名称


parameter

parameter(parameter?): IParameter

获取或设置报告表中的参数

代码示例

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(); // get the reportsheet parameter
parameter.customerId = "VINET";
report.parameter(parameter); // set the parameter.
report.regenerateReport(); // regenerate reportsheet according to the new parameter.

参数

属性名 类型
parameter? IParameter

返回值

IParameter

报告表格当前工作参数


printInfo

printInfo(value?): ReportSheet | PrintInfo

获取或设置报告表的打印信息

代码示例

// set the paper size.
const printInfo = reportSheet.printInfo();
printInfo.paperSize(new GC.Spread.Sheets.Print.PaperSize(GC.Spread.Sheets.Print.PaperKind.a3));

参数

属性名 类型
value? PrintInfo

返回值

ReportSheet | PrintInfo

如果未设置值,请返回报告表的打印信息;否则,返回报告表


printPageIndexes

printPageIndexes(pageIndexes?): number[]

获取或设置将要打印的页面索引阵列。空数组表示打印所有页面

代码示例

// print only the first and fifth pages of the current report.
reportSheet.printPageIndexes([0, 4]);
reportSheet.options.printAllPages = true;
spread.print();

// clear the print page indexes setting.
reportSheet.printPageIndexes([]);

参数

属性名 类型 说明
pageIndexes? number[] 打印页索引数组(以 0 开始)

返回值

number[]

返回将要打印的页面索引数组


refresh

refresh(): void 刷新当前的报告表,所有渲染模式都可以支持此功能 设计模式:刷新模板缓存并重绘 预览模式:重新生成当前报表 分页预览模式:重新生成当前报表

代码示例

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

regenerateReport(): void

基于当前模板生成报告

代码示例

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?): RenderMode

获取或设置渲染模式

代码示例

// switch to design mode.
reportSheet.renderMode('Design');

// switch to preview mode.
reportSheet.renderMode('Preview');

// switch to paginated preview mode.
reportSheet.renderMode('PaginatedPreview');

参数

属性名 类型 说明
renderMode? RenderMode 渲染模式

返回值

RenderMode

渲染模式


repaint

repaint(): void

重绘当前报表

返回值

void


resetCellValue

resetCellValue(row, col): void

重置指定单元格的值

代码示例

// If the A2 cell's value is modified, resetCellValue can reset the A2 cell to its original value.
reportSheet.resetCellValue(1, 0);

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

void


setParametersUI

setParametersUI(host, initParametersUI, onChange): void

设置报表的参数面板

代码示例

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:"); // add static label cell
    sheet.getCell(3, 4).bindingPath("customerId").tag("customerId"); // add parameter binding path and tag to this cell
    const submitButton = new GC.Spread.Sheets.CellTypes.Button(); // add submit button
    submitButton.text("Submit");
    sheet.getCell(3, 5).cellType(submitButton).tag("submitButton"); // set button cell type and tag to this cell
}
function onChanged (reportSheet, changedArgs) {
    if (changedArgs.tag === "submitButton") { // submit button clicked.
        reportSheet.regenerateReport();
    }
    if (changedArgs.tag === "customerId") {
        changedArgs.newValue = changedArgs.newValue.toUpperCase(); // update newValue here.
    }
}

参数

属性名 类型 说明
host string | HTMLElement 参数面板的 HTML 容器 ID
initParametersUI InitParametersUIFunctionType 初始化参数面板的回调
onChange OnChangeFunctionType 当参数面板中值发生变化或按钮被按下时的回调

返回值

void


submit

submit(): void

提交修改的数据,通过 DataManager 调用更新远程接口

代码示例

// submit the changes.
reportSheet.submit();

返回值

void


toWorksheet

toWorksheet(): Worksheet

在当前报告表上生成了一个静态工作表(无公式,无单元合并)

代码示例

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();

返回值

Worksheet

生成的工作表


toggleCollapseState

toggleCollapseState(row, col): void

切换指定单元格的折叠状态

代码示例

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);

参数

属性名 类型 说明
row number 行索引
col number 列索引

返回值

void


unbind

unbind(type, fn?): void

删除事件与报告表的绑定

代码示例

//This example unbind the ReportSheetDataChanged event after first data changing.
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);
});
// after reportsheet edit / update / delete records in UI will trigger ReportSheetDataChanged event.

参数

属性名 类型 说明
type string 事件类型
fn? Function 指定要删除绑定的函数

返回值

void


updateCellValue

updateCellValue(row, col, value): void

更新指定单元格的值

代码示例

// update the A2 cell's value.
reportSheet.updateCellValue(1, 0, 'test');

参数

属性名 类型 说明
row number 行索引
col number 列索引
value any 单元格的新值

返回值

void