FPdfTable
Facade for one editable structured PDF table.
Access
Access through:
Inheritance
Extends FPdfPageElement. Its inherited members are available on this object.
Example
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.insertTable({ rowCount: 2, columnCount: 3, cellTexts: ['A', 'B', 'C'],})console.log(table.getRowCount()) // 2console.log(table.getColumnCount()) // 3table.resize(3, 4)Setup
Register @univerjs-pro/pdfs or a preset that includes it. In plugin mode, import @univerjs-pro/pdfs/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/pdfs
FPdfTable.getCell
Return a live table-cell Facade by zero-based coordinates.
getCell(row: number, column: number): FPdfTableCellParameters
row— Required. The zero-based row index.column— Required. The zero-based column index.
Returns
The live cell Facade.
Throws
If either coordinate is outside the current table.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]const cell = table?.getCell(0, 0)console.log(cell?.getText())Types: FPdfTableCell
Package: @univerjs-pro/pdfs · Type definitions
FPdfTable.getColumnCount
Return the current table column count.
getColumnCount(): numberReturns
The column count.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]console.log(table?.getColumnCount())Package: @univerjs-pro/pdfs · Type definitions
FPdfTable.getRowCount
Return the current table row count.
getRowCount(): numberReturns
The row count.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]console.log(table?.getRowCount())Package: @univerjs-pro/pdfs · Type definitions
FPdfTable.getTheme
Return a detached table-theme descriptor.
getTheme(): Readonly<IPdfTableTheme>Returns
The current theme snapshot.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]console.log(table?.getTheme())Types: IPdfTableTheme · Readonly
Package: @univerjs-pro/pdfs · Type definitions
FPdfTable.resize
Resize the table grid while preserving overlapping cells by position.
resize(rowCount: number, columnCount: number): thisParameters
rowCount— Required. The positive new row count.columnCount— Required. The positive new column count.
Returns
This table Facade for chaining.
Throws
If either count is invalid or the table would exceed 10,000 cells.
If the table is stale or the durable command is rejected.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]if (table) { table.resize(3, 4)}Package: @univerjs-pro/pdfs · Type definitions
FPdfTable.setTheme
Replace the table theme and conditional style regions.
setTheme(theme: IPdfTableTheme): thisParameters
theme— Required. The new table theme.
Returns
This table Facade for chaining.
Throws
If the table is stale or the durable command is rejected.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]if (table) { const preset = univerAPI.getPdfTableThemePresets()[3] table.setTheme({ styleId: preset.id, options: { firstRow: true, }, })}Types: IPdfTableTheme
Package: @univerjs-pro/pdfs · Type definitions
你觉得这篇文档如何?