Socket
Socket
Sign inDemoInstall

export-xlsx

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

export-xlsx


Version published
Maintainers
1
Created

Readme

Source

export-xlsx · GitHub license Build Status npm version

Export Excel

  • support formula
  • hierarchy structure
  • multi-headers

Getting started

$ npm i -S export-xlsx

Usage

Make excel setting

import { alignment, defaultDataType } from 'export-xlsx';

// Export settings
export const SETTINGS_FOR_EXPORT = {
  // Table settings
  fileName: 'example',
  workSheets: [
    {
      sheetName: 'example',
      startingRowNumber: 2,
      gapBetweenTwoTables: 2,
      tableSettings: {
        table1: {
          tableTitle: "Score",
          headerGroups: [
            {
              name: '',
              key: 'void',
              groupKey: 'directions',
            },
            {
              name: 'Science',
              key: 'science',
              groupKey: 'directions',
            },
            {
              name: 'Directions',
              key: 'directions',
            },
          ],
          headerDefinition: [
            {
              name: '#',
              key: 'number',
            },
            {
              name: 'Name',
              key: 'name',
            },
            {
              name: 'SUM',
              key: 'sum',
              groupKey: 'void',
              rowFormula: '{math}+{physics}+{chemistry}+{informatics}+{literature}+{foreignLang}',
            },
            {
              name: 'Mathematics',
              key: 'math',
              groupKey: 'science',
            },
            {
              name: 'Physics',
              key: 'physics',
              groupKey: 'science',
            },
            {
              name: 'Chemistry',
              key: 'chemistry',
              groupKey: 'science',
            },
            {
              name: 'Informatics',
              key: 'informatics',
              groupKey: 'science',
            },
            {
              name: 'Literature',
              key: 'literature',
              groupKey: 'science',
            },
            {
              name: 'Foreign lang.',
              key: 'foreignLang',
              groupKey: 'science',
            },
            {
              name: 'AVG',
              key: 'avg',
              groupKey: 'void',
              rowFormula: '{sum}/6',
            }
          ],
        }
      }
    },
  ],
};

How to use

import ExcelExport from 'export-xlsx';
import { SETTINGS_FOR_EXPORT } from './setting';

const data = {
  table1: [
    {
      number: 1,
      name: 'Jack',
      sum: '',
      math: 1,
      physics: 2,
      chemistry: 2,
      informatics: 1,
      literature: 2,
      foreignLang: 1,
      avg: '',
    },
    {
      number: 2,
      name: 'Peter',
      sum: '',
      math: 2,
      physics: 2,
      chemistry: 1,
      informatics: 2,
      literature: 2,
      foreignLang: 1,
      avg: '',
    },
  ]
};

const excelExport = new ExcelExport();
excelExport.downloadExcel(SETTINGS_FOR_EXPORT, data);

Result

Contact

If you have any questions, please contact me root@laravue.org

License

The MIT license

Keywords

FAQs

Last updated on 16 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc