Skip to content
Snippets Groups Projects
Commit 9b659cf9 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Fix placement of formulas & styles in XLSX

parent 704aa2a4
Branches
Tags 0.0.279
No related merge requests found
Pipeline #6845 passed
......@@ -227,7 +227,7 @@
const tableByEntityKey: { [key: string]: Array<Array<unknown>> } = {} // Array of rows
for (const variable of variables) {
const columnIndex = (columnIndexByEntityKey[variable.entity] =
(columnIndexByEntityKey[variable.entity] ?? 0) + 1)
(columnIndexByEntityKey[variable.entity] ?? -1) + 1)
const values = valuesByCalculationNameByVariableName[variable.name].law
let table = tableByEntityKey[variable.entity]
if (table === undefined) {
......@@ -235,7 +235,7 @@
}
for (const [rowIndex, cell] of [variable.name, ...values].entries()) {
let row = table[rowIndex]
if (row === undefined) {
if (rowIndex === table.length) {
row = []
table.push(row)
}
......@@ -265,8 +265,7 @@
e: { c: columnIndex, r: table.length - 1 },
})
// TODO: Improve type detection (for date, etc).
const sampleCell = table[1][0]
const sampleCellType = typeof sampleCell
const sampleCellType = typeof values[0]
const t =
sampleCellType === "boolean"
? "b"
......@@ -310,9 +309,9 @@
XLSX.utils.book_append_sheet(workbook, worksheet, entityKey)
for (const [columnIndex, variableName] of (
table[0] as string[]
).entries()) {
for (const [columnIndex, cell] of table[0].entries()) {
const variableName =
typeof cell === "string" ? cell : (cell as { v: string }).v
const vectorRange = XLSX.utils.encode_range({
s: { c: columnIndex, r: 1 },
e: { c: columnIndex, r: table.length - 1 },
......@@ -328,7 +327,7 @@
}
}
XLSX.writeFileXLSX(workbook, "leximpact.xlsx", { compression: true })
XLSX.writeFile(workbook, "leximpact.xlsx", { compression: true })
}
function openWebSocket() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment