Skip to content

Commit

Permalink
[fix]: corrupt xlsx fix by wrapping sheet with worksheet
Browse files Browse the repository at this point in the history
  • Loading branch information
maifeeulasad committed Oct 17, 2022
1 parent bc10924 commit 0ee7071
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/xl/worksheets/sheet1.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,29 @@ const cell = (row: string, value: ICellEntry) =>

const cellValue = (value: ICellEntry) => `<v>${value.value}</v>`;

const generateSheet1Xml = (grid: ICellEntry[][]) =>
const generateSheetData = (grid: ICellEntry[][]) =>
`<sheetData>${grid
.map((ro: ICellEntry[], index: number) => row(index, ro))
.join("")}</sheetData>`;




const generateSheet1Xml = (
grid: ICellEntry[][]
) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{6A0CD924-A203-41BB-8331-42E46B7D5F20}">
<dimension ref="B3:I7" />
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0">
<selection activeCell="B3" sqref="B3:D4" />
</sheetView>
</sheetViews>
<sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25" />
${generateSheetData(grid)}
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />
</worksheet>
`;


export { ICellEntry, generateSheet1Xml };

0 comments on commit 0ee7071

Please sign in to comment.