javascript - Make a data table using exceljs - Stack Overflow

I'm trying to format some data into a Excel table, I already have the data written in the Excel fi

I'm trying to format some data into a Excel table, I already have the data written in the Excel file, but I want it as a table, is there any way to do this, if not, is there any way with another npm package

I'm trying to format some data into a Excel table, I already have the data written in the Excel file, but I want it as a table, is there any way to do this, if not, is there any way with another npm package

Share Improve this question asked Feb 19, 2020 at 21:17 William DamWilliam Dam 1292 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You could convert the range to table:

const sheet = context.workbook.worksheets.getItem("Sample");
let expensesTable = sheet.tables.add("A1:E7", true);
expensesTable.name = "ExpensesTable";

here is the sample gist that you could have a try https://gist.github./lumine2008/8eccb88f7fccf34b63c7ecd5fd05aaea

Source: Tables allow for in-sheet manipulation of tabular data.

import * as exceljs from 'exceljs';

const workbook = new exceljs.Workbook();
const worksheet = workbook.addWorksheet('William');

// add a table to a sheet
worksheet.addTable({
  name: 'Dam',
  ref: 'A1',
  headerRow: true,
  totalsRow: true,
  style: {
    theme: 'TableStyleDark3',
    showRowStripes: true,
  },
  columns: [
    {name: 'Date', totalsRowLabel: 'Totals:', filterButton: true},
    {name: 'Amount', totalsRowFunction: 'sum', filterButton: false},
  ],
  rows: [
    [new Date('2019-07-20'), 70.10],
    [new Date('2019-07-21'), 70.60],
    [new Date('2019-07-22'), 70.10],
  ],
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745308005a4621831.html

相关推荐

  • javascript - Make a data table using exceljs - Stack Overflow

    I'm trying to format some data into a Excel table, I already have the data written in the Excel fi

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信