LuisEnMarroquin / json-as-xlsx

Create excel from json npm package
https://www.npmjs.com/package/json-as-xlsx
MIT License
159 stars 26 forks source link

Receiving file without downloading #60

Closed brian-sa closed 1 year ago

brian-sa commented 1 year ago

Hi, I'm wondering if it is possible to use this library to generate the excel file but not initiate the download? Looking to add the generated file to a zip file and download that instead.

elyse0 commented 1 year ago

Yep, you can get the file to an ArrayBuffer setting writeOptions.type to "buffer".

This is how its used in the Express demo https://github.com/LuisEnMarroquin/json-as-xlsx/blob/main/packages/demo-express/src/server.ts

const settings: ISettings = {
  writeOptions: {
    type: "buffer",
    bookType: "xlsx",
  },
}

 const buffer = xlsx(data, settings)
LuisEnMarroquin commented 1 year ago

Thanks @elyse0 I am closing this question