Support XLSX 1904 date imports
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
workbookPrintAreas,
|
||||
workbookRelationshipTargets,
|
||||
workbookSheetRefs,
|
||||
workbookUsesDate1904,
|
||||
worksheetXmlToAutoFilter,
|
||||
worksheetXmlToCells,
|
||||
worksheetXmlToCellFormats,
|
||||
@@ -615,6 +616,38 @@ describe("excellOffice OOXML helpers", () => {
|
||||
).toBe("sheet-7");
|
||||
});
|
||||
|
||||
it("detects the XLSX 1904 date system flag from workbook properties", () => {
|
||||
expect(workbookUsesDate1904({ workbook: { workbookPr: { date1904: "1" } } })).toBe(true);
|
||||
expect(workbookUsesDate1904({ workbook: { workbookPr: { date1904: "true" } } })).toBe(true);
|
||||
expect(workbookUsesDate1904({ workbook: { workbookPr: { date1904: "0" } } })).toBe(false);
|
||||
});
|
||||
|
||||
it("converts imported XLSX 1904 date serials to the QExcell 1900 serial system", async () => {
|
||||
const zip = new JSZip();
|
||||
zip.file(
|
||||
"xl/workbook.xml",
|
||||
`<workbook><workbookPr date1904="1"/><sheets><sheet name="Dates" sheetId="1" r:id="rId1"/></sheets></workbook>`
|
||||
);
|
||||
zip.file(
|
||||
"xl/_rels/workbook.xml.rels",
|
||||
`<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Target="worksheets/sheet1.xml"/></Relationships>`
|
||||
);
|
||||
zip.file("xl/styles.xml", `<styleSheet><cellXfs count="3"><xf numFmtId="0"/><xf numFmtId="14"/><xf numFmtId="20"/></cellXfs></styleSheet>`);
|
||||
zip.file(
|
||||
"xl/worksheets/sheet1.xml",
|
||||
`<worksheet><sheetData><row r="1"><c r="A1" s="1"><v>43465</v></c><c r="B1"><v>5</v></c><c r="C1" s="2"><v>0.5</v></c></row></sheetData></worksheet>`
|
||||
);
|
||||
|
||||
const blob = await zip.generateAsync({
|
||||
type: "blob",
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
});
|
||||
const imported = await importXlsxFile(new File([blob], "Date1904.xlsx", { type: blob.type }));
|
||||
|
||||
expect(imported.sheets[0].cells).toEqual({ A1: "44927", B1: "5", C1: "0.5" });
|
||||
expect(imported.sheets[0].cellFormats).toEqual({ A1: { numberFormat: "m/d/yy" }, C1: { numberFormat: "h:mm" } });
|
||||
});
|
||||
|
||||
it("сохраняет и импортирует активный лист XLSX через workbookView activeTab", async () => {
|
||||
const blob = await exportXlsxBlob({
|
||||
id: "book-1",
|
||||
|
||||
Reference in New Issue
Block a user