Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mr-excel

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mr-excel

A versatile JavaScript library for effortlessly generating .xlsx files from input objects. Seamlessly create Excel spreadsheets with data, formatting, formulas, and more.

  • 0.9.5
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.7K
increased by1.4%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

Welcome to our JavaScript library designed to effortlessly generate .xlsx files from input objects. This versatile library offers exceptional flexibility and can seamlessly operate on both the client and backend sides of applications.

Our library offers comprehensive support for a wide range of features, including data formatting, formulas, styles, merged cells, and grouped rows.

Installation

Via CDN

You can utilize our library, which comes bundled with Vite, by including the following link:

<script src="https://unpkg.com/mr-excel@latest/dist2/excel-table.js"></script>

Alternatively, you have the option to use the bundle with Webpack by incorporating the link provided below:

<script src="https://unpkg.com/mr-excel@latest/dist2/excel-table.js"></script>

Easily integrate our library into your project using either of these methods, and unlock efficient generation of Excel tables with exceptional flexibility.

Using a Package Manager To seamlessly integrate our library, you can install it using your preferred package manager:

Via npm:

npm install mr-excel

Using yarn:

npm install mr-excel

Alternatively, you have the option to use pnpm:

npm install mr-excel

Choose the package manager that suits your workflow, and effortlessly bring the power of our library into your project, enabling smooth generation of Excel tables with ease and efficiency.

Getting Started

After adding the library to your project, generating XLSX files becomes straightforward. You can achieve this by creating a data object similar to the code snippet below:

//<https://colorhunt.co/palette/f9ed69f08a5db83b5e6a2c70>
const colorPalette = {
  c1: "F9ED69",
  c2: "#F08A5D",
  c3: "B83B5E",
  c4: "6A2C70",
};
const data = {
  creator: "mr",
  created: "2023-08-06T07:22:40Z",
  modified: "2023-08-06T07:22:40Z",
  styles: {
    formulaStyle: {
      fg: "B83B5E",
      border: {
        full: {
          style: "medium",
          color: "F9ED69",
        },
      },
    },
    headerStyle: {
      fg: "F9ED69",
      fontColor: "#F08A5D",
      bold: true,
    },
    rowStyle: {
      fg: "#F08A5D",
      fontColor: "F9ED69",
    },
  },
  sheet: [
    {
      name: "Test",
      formula: {
        B16: {
          type: "SUM",
          start: "B2",
          end: "B8",
          styleId: "formulaStyle",
        },
      },
      tabColor: "B83B5E",
      headers: [
        {
          label: "test",
          text: "Test",
        },
        {
          label: "_id",
          text: "ID",
          formula: {
            type: "MAX",
            styleId: "formulaStyle",
          },
        },
      ],
      data: [
        {
          _id: 0.3,
          test: "test1",
        },
        {
          _id: 2,
          test: "dsssssssssssss",
        },
        {
          _id: 3,
          test: "test3",
        },
        {
          _id: 4,
          test: "test4",
        },
        {
          _id: 5,
          test: "test5",
        },
        {
          _id: 6,
          test: "test6",
        },
        {
          _id: 7,
          test: "test7",
        },
        {
          _id: 8,
          test: "test8",
        },
        {
          _id: 9,
          test: "test9",
        },
        {
          _id: 10,
          test: "test10",
        },
        {
          _id: 11,
          test: "test11",
        },
      ],
    },
    {
      headers: [
        {
          label: "test",
          text: "Test",
        },
        {
          label: "_id",
          text: "ID",
        },
      ],
      data: [
        {
          _id: 1,
          test: "test1",
        },
        {
          _id: 2,
          test: "test2",
        },
        {
          _id: 3,
          test: "test3",
        },
        {
          _id: 4,
          test: "test4",
        },
        {
          _id: 5,
          test: "test5",
        },
        {
          _id: 6,
          test: "test6",
        },
        {
          _id: 7,
          test: "test7",
        },
        {
          _id: 8,
          test: "test8",
        },
        {
          _id: 9,
          test: "test9",
        },
        {
          _id: 10,
          test: "test10",
        },
        {
          _id: 11,
          test: "test11",
        },
      ],
    },
  ],
};
ExcelTable.generateExcel(data);

API

PropertyTypeDescription
ProtectionOption{ [key in ProtectionOptionKey]: "0" | "1"; }Options for protecting sheets
ProtectionOptionKeyProtectionOptionKeyKeys for protection options
AlignmentOptionAlignmentOptionOptions for cell alignment
AlignmentOptionKeyAlignmentOptionKeyKeys for alignment options
BorderDirection"full" | "top" | "left" | "right" | "bottom"Directions for cell borders
BorderOption{ [key in BorderDirection]: { color: string; style: string; }; }Options for cell borders
Header{ label: string; text: string; size?: number; formula?: { type: FormulaType; styleId?: string; }; }Header cell properties
DataDataOptionsData cell properties
DataOptionsDataOptionsOptions for data cells
MergeRowConditionMap{ [columnKey: string]: { inProgress: boolean; start: number; }; }Merge row conditions map
StyleCellConditionFunction(data: Header | string | number | undefined, object: Header | Data, colIndex: number, rowIndex: number, fromHeader: boolean, stylekeys: string[]) => string;Function for styling cells
MergeRowDataConditionFunction(data: Header | string | number | undefined, key: string | null, index: number, fromHeader: boolean) => boolean;Function for merging row conditions
SortAndFilter{ mode: "all" | "ref"; ref: string; }Sort and filter options
SheetSheetProperties of a sheet
HeaderRowOption{ outlineLevel: "string"; }Options for header row
StyleMapperStyleMapperStyle mapping properties
FormulaType"AVERAGE" | "SUM" | "COUNT" | "MAX" | "MIN"Types of formulas
StylesStylesStyle properties
FormatMap{ [format: string]: { key: number; value?: string; }; }Format mapping properties
FormulaSetting{ type: FormulaType; start: string; end: string; styleId?: string; }Formula settings
Formula{ [insertCell: string]: FormulaSetting; }Formulas for cells
ExcelTableExcelTableProperties of an Excel table

Keywords

FAQs

Package last updated on 09 Aug 2023

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc