Change XLSX imports to accodomate rollup bundles
This commit is contained in:
parent
fae82b575e
commit
1b10a06205
@ -69,6 +69,8 @@ const ods = await createOdsFile(content)
|
||||
// ods is an ArrayBuffer representing an ods file with the content described by the Map
|
||||
```
|
||||
|
||||
(and there is a tool to test file creation:
|
||||
`node tools/create-an-ods-file.js > yo.ods`)
|
||||
|
||||
#### Low-level
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
//@ts-check
|
||||
|
||||
import XLSX from 'xlsx'
|
||||
|
||||
import {write, utils} from 'xlsx'
|
||||
import {tableRawContentToValues} from './shared.js'
|
||||
|
||||
/** @import {SheetName, SheetRawContent, SheetRowRawContent, SheetCellRawContent} from './types.js' */
|
||||
|
||||
const officeVersion = '1.2'
|
||||
/** @import {SheetName, SheetRawContent} from './types.js' */
|
||||
|
||||
/**
|
||||
* Crée un fichier .ods à partir d'un Map de feuilles de calcul
|
||||
@ -14,14 +11,14 @@ const officeVersion = '1.2'
|
||||
* @returns {Promise<ArrayBuffer>}
|
||||
*/
|
||||
export async function createOdsFile(sheetsData) {
|
||||
const workbook = XLSX.utils.book_new();
|
||||
const workbook = utils.book_new();
|
||||
|
||||
const sheetsDataValues = tableRawContentToValues(sheetsData)
|
||||
|
||||
for(const [sheetName, table] of sheetsDataValues){
|
||||
const worksheet = XLSX.utils.aoa_to_sheet(table);
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
||||
const worksheet = utils.aoa_to_sheet(table);
|
||||
utils.book_append_sheet(workbook, worksheet, sheetName);
|
||||
}
|
||||
|
||||
return XLSX.write(workbook, {bookType: 'ods', type: 'array'});
|
||||
return write(workbook, {bookType: 'ods', type: 'array'});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user