SheetJS / sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
https://sheetjs.com/
Apache License 2.0
35.04k stars 8k forks source link

Writing a workbook with multiple sheets to one file resulting in only one sheet data #1367

Closed priya0412 closed 5 years ago

priya0412 commented 5 years ago

const ws = XLSX.utils.aoa_to_sheet(rows); const ws1 = XLSX.utils.aoa_to_sheet(rows1); / write workbook (use type 'binary') / const wb = XLSX.utils.book_new(); //XLSX.utils.book_append_sheet(wb, ws,"sheet1"); XLSX.utils.book_appendsheet(wb, ws1,"sheet2"); const stream = XLSX.writeFile(wb, `..\out\processed\data${site}.csv`, { flag: 'w+' });

priya0412 commented 5 years ago

const ws = XLSX.utils.aoa_to_sheet(rows); const ws1 = XLSX.utils.aoa_to_sheet(rows1); / write workbook (use type 'binary') / const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws,"sheet1"); XLSX.utils.book_appendsheet(wb, ws1,"sheet2"); const stream = XLSX.writeFile(wb, ..\out\processed\data${site}.csv, { flag: 'w+' });

reviewher commented 5 years ago

You're writing to CSV, a single-sheet format. https://github.com/SheetJS/js-xlsx#supported-output-formats has a table of the supported output formats. multiple sheets are written for formats which are marked as "multi" in the sheets column, namely xlsx, xlsx, xlsx, biff8, biff5, xlml, ods, fods

priya0412 commented 5 years ago

Thankyou for your Reply Reviewher. Now I have xlsx with multiple sheets, how to write it to one .CSV .