npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jz-excel

v1.1.0

Published

Excel transform Json tools

Downloads

3

Readme

Jz-Excel

[English] [中文]

[GitHub]

A Excel ← Transform → Json tool.

Using this tool, you can convert Excel to Json, and also can convert Json to Excel. This works well for exporting tabular data from the page.

  • Excel to Json: is the overall simplified parsing tool for the LuckySheet open source framework. According to the content of its framework, all the contents are sorted out and modified one by one to create the present parsing tool.

  • Json to Excel:Use the exceljs framework for parsing assembly.

Features

  • Convert data by row and by column
  • You can convert images
  • Matches the Luckysheet format

Demo

Demo

Install

npm i jz-excel

or

yarn add jz-excel

Link

<script src="https://cdn.jsdelivr.net/npm/jz-excel/dist/index.min.js"></script>

Note : The node environment is recommended, version 1.0.2 is required in the browser environment. The new version has known problems that cause unreadable data~~~

Use

It very easy to use.

Parse Excel

import { parseExcel } from "jz-excel"

and use the function:

/**
 * @param {File} excel
 * @param {(data: null | object, err: undefined | any) => any} cb
 */
parseExcel(excel, function (data, err) {
  if (data) {
    // success

    // NOTICE: In order not to change Luckysheet's data structure, the text content may come in two formats that require some processing
    data.sheets[0].celldata.forEach(item => {
      // extract all the content
      let content = item?.v?.v ?? "";
      if (item?.v?.ct) {
        content = item?.v.ct.s.reduce((per, cur) => per + cur.v, "");
      }

      // other code...
    });
  } else {
    // failure
  }
});

data is object | null, includes info and sheets, same as Luckysheet.

Export Excel

import { ExportExcel } from "jz-excel";

It's a class that adds worksheet, contents, images(if any) in that order, and then it's ready to export.

var excel = new JzExcel.ExportExcel("my company");

var sheetName = "mySheet";
excel.addSheet(sheetName);
excel.addContents(sheetName, data);
// add image must be a async operation
excel.addImagesAsync(sheetName, images).then(() => {
  excel.export("my-file");
});

For data formats, refer to the corresponding TypeScript.

Typescript support

I wrote a simple type support.

Parse method declaration:

declare function parseExcel(
  excel: File,
  cb: (
    data: null | {
      info: JExcelInfo;
      sheets: Array<JExcelSheets>;
    },
    err: undefined | any
  ) => any
): void;

Export class declaration:

declare class ExportExcel {
  constructor(companyName?: string);

  setCompanyName(name: string): void;
  addSheet(name: string): string;
  addContents(
    sheetName: string,
    contents: Array<
      Array<{
        value: ExcelJS.CellValue;
        options?: {
          width?: number;
          height?: number;
          font?: Partial<ExcelJS.Font>;
          alignment?: Partial<ExcelJS.Alignment>;
        };
      }>
    >
  ): void;
  addImagesAsync(
    sheetName: string,
    images: Array<{
      value: string;
      isBase64: boolean;
      r: number;
      c: number;
      offset?: number;
    }>
  ): Promise<any>;
  export(filename: string): Promise<any>;
}

Special

Luckysheet

Note: if there is any improper, please contact me to delete.

License

MIT