SpreadsheetImportProgress
SpreadsheetImportProgress:
{}How far opening a spreadsheet has got.
Experimental: the spreadsheet API may change or be removed in any release, including minor and patch releases.
Each report describes one phase: done and total count that phase’s work and start again when the next
phase begins, so show progress per phase rather than as one number for the whole file.
Examples
Section titled “Examples”// A status line that follows the phases: "Reading sheet 2 of 5 — 40%", then "Indexing — 63%", then "Opening…"const percent = ({ done, total }: SpreadsheetImportProgress) =>
const { phase, sheet, sheetCount } = progress; switch (phase) { case 'reading': ? 'Reading…' : `Reading sheet ${sheet + 1} of ${sheetCount}${percent(progress)}`; case 'indexing': return `Indexing${percent(progress)}`; case 'loading': return 'Opening…'; }};
const spreadsheet = await system.importSpreadsheet(file, { onProgress: (progress) => statusLabel.replaceChildren(describe(progress)),});// One <progress> bar per phase. A phase with no total shows its bar as indeterminate, and a phase the file reading: readingBar, indexing: indexingBar, loading: loadingBar,};
const spreadsheet = await system.importSpreadsheet(file, { onProgress: ({ phase, done, total }) => { const bar = bars[phase]; },});Properties
Section titled “Properties”
readonlyphase:SpreadsheetImportPhase
Which sheet is being worked on, 0-based, or null in a phase that is not about one sheet.
sheetCount
Section titled “sheetCount”How many sheets the spreadsheet has, or null before the file has said.
readonlydone:number
How much of this phase is done, counted in SpreadsheetImportProgress.unit.
What done is counted towards, or null when the file states no total for this phase.
Never a guess. A sheet in the file is not required to declare how many rows it has, and one that declares a
figure is permitted to be wrong about it — so done may exceed a non-null total. Treat a percentage
built from these as an estimate and clamp it before showing it.
readonlyunit:"bytes"|"rows"|"spans"|"sheets"
What done and total count, which depends on the phase.
readingcountsrowsof the sheet named bysheet, after asheetsreport as each sheet starts.indexingcountsbytesof the file, orspans— blocks of rows — when a spreadsheet saved by an earlier version has to be read a second time.loadingreportssheetsonce, with no total.