@soyzr/table-to-excel
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

table-to-excel

API

typescript interface

type IDataArray = Array<any[]>;

type ICB = (err: any, data?: any) => any;

interface IDataSource {
    title?: IDataArray;
    body: IDataArray;
}

interface ITableProp {
    filename?: string;
    dataSource?: IDataSource;
    table?: string | HTMLElement;
    callback?: ICB;
}

example

dataSource

const TableToExcel = require("@soyzr/table-to-excel");

new TableToExcel({
    filename: "table_to_excel_list",
    dataSource: {
        title: [["Message", null, null, "Other"], ["Name", "Sex", "Age", "Time"]],
        body: [["ZA", "male", 18, new Date()], ["LS", "male", 22, new Date()]]
    }
});

table

  1. HTMLElement
const TableToExcel = require("@soyzr/table-to-excel");

const table = document.querySelector("table");

const btn = document.querySelector("button");

btn.addEventListener(
    "click",
    function() {
        new TableToExcel({
            filename: "table_to_excel_list",
            table
        });
    },
    false
);
  1. string
const TableToExcel = require("@soyzr/table-to-excel");

const table = `
<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Sex</th>
            <th>Age</th>
            <th>Time</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>ZS</td>
            <td>male</td>
            <td>18</td>
            <td>2019103 0</td>
        </tr> 
    </tbody>
</table>
`;

new TableToExcel({
    filename: "table_to_excel_list",
    table
});

Package Sidebar

Install

npm i @soyzr/table-to-excel

Weekly Downloads

0

Version

1.2.4

License

ISC

Unpacked Size

16.8 kB

Total Files

7

Last publish

Collaborators

  • soyzr