@@ -6,6 +6,7 @@ import type {
66 SpreadsheetOptions ,
77 SpreadsheetType ,
88} from './types'
9+ import { Buffer } from 'node:buffer'
910
1011export const spreadsheet : Spreadsheet = Object . assign (
1112 ( data : Content ) => ( {
@@ -59,7 +60,8 @@ export const spreadsheet: Spreadsheet = Object.assign(
5960 store : async ( { content } : SpreadsheetContent , path : string ) : Promise < void > => {
6061 try {
6162 await Bun . write ( path , content )
62- } catch ( error ) {
63+ }
64+ catch ( error ) {
6365 throw new Error ( `Failed to store spreadsheet: ${ ( error as Error ) . message } ` )
6466 }
6567 } ,
@@ -107,7 +109,7 @@ export function generateCSVContent(content: Content): string {
107109 const rows = [ content . headings , ...content . data ]
108110
109111 return rows
110- . map ( ( row ) =>
112+ . map ( row =>
111113 row
112114 . map ( ( cell ) => {
113115 const cellString = String ( cell )
@@ -165,7 +167,7 @@ export function generateExcelContent(content: Content): Uint8Array {
165167 <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>
166168 </Relationships>`
167169
168- const files : Array < { name : string ; content : Uint8Array } > = [
170+ const files : Array < { name : string , content : Uint8Array } > = [
169171 { name : '[Content_Types].xml' , content : new Uint8Array ( Buffer . from ( contentTypes ) ) } ,
170172 { name : '_rels/.rels' , content : new Uint8Array ( Buffer . from ( rels ) ) } ,
171173 { name : 'xl/workbook.xml' , content : workbook } ,
@@ -177,7 +179,7 @@ export function generateExcelContent(content: Content): Uint8Array {
177179 const header = new Uint8Array ( 30 + file . name . length )
178180 const headerView = new DataView ( header . buffer )
179181
180- headerView . setUint32 ( 0 , 0x04034b50 , true ) // 'PK\x03\x04'
182+ headerView . setUint32 ( 0 , 0x04034B50 , true ) // 'PK\x03\x04'
181183 headerView . setUint32 ( 4 , 0x0008 , true )
182184 headerView . setUint32 ( 18 , compressedContent . length , true )
183185 headerView . setUint32 ( 22 , file . content . length , true )
@@ -193,7 +195,7 @@ export function generateExcelContent(content: Content): Uint8Array {
193195 const header = new Uint8Array ( 46 + file . name . length )
194196 const headerView = new DataView ( header . buffer )
195197
196- headerView . setUint32 ( 0 , 0x02014b50 , true ) // 'PK\x01\x02'
198+ headerView . setUint32 ( 0 , 0x02014B50 , true ) // 'PK\x01\x02'
197199 headerView . setUint16 ( 4 , 0x0014 , true )
198200 headerView . setUint16 ( 6 , 0x0008 , true )
199201 headerView . setUint32 ( 8 , 0x0008 , true )
@@ -213,10 +215,10 @@ export function generateExcelContent(content: Content): Uint8Array {
213215
214216 const endOfCentralDirectory = new Uint8Array ( 22 )
215217
216- const totalSize =
217- zipData . reduce ( ( acc , { header, compressedContent } ) => acc + header . length + compressedContent . length , 0 ) +
218- centralDirectory . reduce ( ( acc , header ) => acc + header . length , 0 ) +
219- endOfCentralDirectory . length
218+ const totalSize
219+ = zipData . reduce ( ( acc , { header, compressedContent } ) => acc + header . length + compressedContent . length , 0 )
220+ + centralDirectory . reduce ( ( acc , header ) => acc + header . length , 0 )
221+ + endOfCentralDirectory . length
220222
221223 // Create a single Uint8Array with the total size
222224 const result = new Uint8Array ( totalSize )
0 commit comments