Skip to content

Project showcasing a lightweight .xlsx download utility for client-side js.

Notifications You must be signed in to change notification settings

maxx-420/js-to-xlsx

Repository files navigation

js-to-xlsx


📝 Table of Contents

🧐 About

This project showcases downloading client side .xlsx files with a few customization option. Unlike SheetJS, this is a lightweight solution(<100kb). Lots of room for improvement. :)

🏁 Usage

npm run serve - To serve.

IE supported but requires prod build - npm run preview


const data = [{...}] (Array of objects)

const config = {
  displayedColums: ['objKey'] // Order of columns to be displayed. If null/empty then alphabetical order is maintained.
  boldHeaders: boolean // default: true,
  upperCaseHeaders: boolean //default: false
  wrapAll: boolean // default: false,
  getCellStyle: (rowIndex, colIndex, cellData) => number/obj // expects a predefined style number or object.
  colConfig: [
    {
      colKey: 'key', //column key
      width: number  // width
    }....
  ]

}
const xlsx = new XLSX().create(data, config)

Dependencies

-JSZip

-FileSaver(can be replaced with a custom solution)

Cell Styling

getCellStyle expects one of the following:

  1. Number:

    normal: 0

    bold text: 2

    wrap text: 10

    wrap & bold text: 11

  2. Object literal containing following properties(optional):

     fontType: 0/2/10/11
     border: true/false,
     fontColor: '#FCFCFC',
     bgColor: '#EEEEEE',
     wrap: true/false,
     alignment: 'right/left/center/flll'
    

⛏️ Built Using

  • Vite JS

🎉 Acknowledgements

  • ExcelHTML5
  • OpenXML

About

Project showcasing a lightweight .xlsx download utility for client-side js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published