FPdfTableCell
Live Facade for one stable cell owned by an FPdfTable.
Access
Access through:
Example
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.insertTable({ rowCount: 2, columnCount: 3, cellTexts: ['A', 'B', 'C'],})const cell = table.getCell(0, 0)console.log(cell.getText())cell.setText('Ready').setStyle({ fill: { color: '#eef3ff' }, fontColor: '#dc2626', horizontalAlignment: univerAPI.Enum.HorizontalAlign.CENTER,})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
FPdfTableCell.getStyle
Return a detached cell-style snapshot.
getStyle(): Readonly<IPdfTableCellStyle>Returns
The current cell-style snapshot.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]const cell = table?.getCell(0, 0)console.log(cell?.getStyle())Types: IPdfTableCellStyle · Readonly
Package: @univerjs-pro/pdfs · Type definitions
FPdfTableCell.getText
Return the current cell text.
getText(): stringReturns
The current cell text.
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())Package: @univerjs-pro/pdfs · Type definitions
FPdfTableCell.setStyle
Update cell container and whole-cell text styles.
setStyle(style: IPdfTableCellStyleOptions): thisParameters
style— Required. The cell-style patch.
Returns
This cell Facade for chaining.
Throws
If the cell is stale or the durable command is rejected.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]const cell = table?.getCell(0, 0)if (cell) { cell.setStyle({ fill: { color: '#eef3ff' }, fontColor: '#dc2626', horizontalAlignment: univerAPI.Enum.HorizontalAlign.CENTER, verticalAlign: univerAPI.Enum.PdfTableCellVerticalAlign.MIDDLE, })}Types: IPdfTableCellStyleOptions
Package: @univerjs-pro/pdfs · Type definitions
FPdfTableCell.setText
Replace the text in a generated single-run table cell.
setText(text: string): thisParameters
text— Required. The replacement cell text.
Returns
This cell Facade for chaining.
Throws
If the cell is stale, unsupported, or the durable command is rejected.
Examples
const pdf = univerAPI.getActivePdf()const page = pdf.getPageByIndex(0)const table = page.getTables()[0]const cell = table?.getCell(0, 0)if (cell) { cell.setText('Ready')}Package: @univerjs-pro/pdfs · Type definitions
你觉得这篇文档如何?