DocAuthSpreadsheetNEW
DocAuthSpreadsheet:
{}An open spreadsheet.
The spreadsheet’s counterpart of DocAuthDocument: what the system hands back when it opens a
file, and what saves and exports it. It does not expose the cells.
Example
Section titled “Example”// Open a file, show it, and save what the user has done to itconst spreadsheet = await system.importSpreadsheet(file);const editor = await system.createSpreadsheetEditor(target, { spreadsheet });// ... user edits the grid ...const saved = await editor.currentSpreadsheet().saveSpreadsheet();Methods
Section titled “Methods”saveSpreadsheet()
Section titled “saveSpreadsheet()”Returns the spreadsheet in the Document Authoring spreadsheet format, as a Blob.
This works at every spreadsheet size, including one with millions of rows, and is the one to prefer. A large spreadsheet is written by streaming, so it never exists in memory as a single value.
Returns
Section titled “Returns”Examples
Section titled “Examples”// Persist to a serverconst saved = await spreadsheet.saveSpreadsheet();await fetch('/api/spreadsheets/123', { method: 'PUT', body: saved });// Save and reopen — the lossless round tripconst saved = await spreadsheet.saveSpreadsheet();const reopened = await system.loadSpreadsheet(saved);saveSpreadsheetJSONString()
Section titled “saveSpreadsheetJSONString()”The same bytes as a JSON string, or an empty string if the spreadsheet is too large to be one.
A very large spreadsheet exceeds the JavaScript engine’s maximum string length; this method then
returns "". Treat an empty result as “use DocAuthSpreadsheet.saveSpreadsheet”.
Returns
Section titled “Returns”Example
Section titled “Example”// Embed the spreadsheet in a JSON request, falling back to a binary upload when it is too large to be aconst json = await spreadsheet.saveSpreadsheetJSONString();if (json === '') { await fetch('/api/spreadsheets/123/content', { method: 'PUT', body: await spreadsheet.saveSpreadsheet() });} else { await fetch('/api/spreadsheets/123', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, });}export()
Section titled “export()”export(
config):Promise<ArrayBuffer>
Exports a snapshot of the spreadsheet in the specified format.
Requires the Spreadsheet Editing component in the license key, and an .xlsx export also
requires XLSX Support. In evaluation mode, a PDF export carries a watermark on every page, and an .xlsx export
carries one on every sheet, both as its background and in its printed header.
A PDF export that names no sheet prints every visible sheet and skips hidden ones. A hidden sheet
named by sheet is still printed.
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”Examples
Section titled “Examples”// Hand the user an .xlsx to downloadconst xlsx = await spreadsheet.export({ format: 'xlsx' });const link = document.createElement('a'););link.download = 'quarterly.xlsx';link.click();// Every visible sheet as one PDF; pass `sheet` for one of them, by 0-based indexconst pdf = await spreadsheet.export({ format: 'pdf' });docAuthSystem()
Section titled “docAuthSystem()”docAuthSystem():
DocAuthSystem
The system this spreadsheet was opened by.