标签: excel4node

Excel4Node:如何下载Excel文件而不保存?

使用 excel4node 我可以将文件写入硬盘。但我想将其作为下载返回,而不将文件保存在服务器上。我认为以下代码是必需的,但不确定如何使用它:

wb.writeToBuffer().then(function(buffer) {
  console.log(buffer);
});
Run Code Online (Sandbox Code Playgroud)

有人对此有什么想法吗?

node.js excel4node

6
推荐指数
2
解决办法
8348
查看次数

如何使用excel4node在excel表中写入数组

我正在使用 package.json 创建一个 excel 文件Excel4node。通过使用此代码

// Require library
var excel = require('excel4node');

// Create a new instance of a Workbook class
var workbook = new excel.Workbook();

// Add Worksheets to the workbook
var worksheet = workbook.addWorksheet('Sheet 1');
var worksheet2 = workbook.addWorksheet('Sheet 2');

// Create a reusable style
var style = workbook.createStyle({
  font: {
    color: '#FF0800',
    size: 12
  },
  numberFormat: '$#,##0.00; ($#,##0.00); -'
});

// Set value of cell A1 to 100 as a number type styled with paramaters …
Run Code Online (Sandbox Code Playgroud)

excel node.js excel4node

5
推荐指数
1
解决办法
4458
查看次数

如何在 NodeJs 中使用 Excel4node 模块在单元格内添加特征线

我需要插入一个带有模块excel4node的多行单元格,在文档中我没有找到任何关于此的信息。我试图插入转义序列,"\n"但没有奏效。这是我的代码:

var xl = require('excel4node');
var wb = new xl.Workbook();
var ws = wb.addWorksheet('Sheet 1');

ws.cell(1, 1).string('first line \n second line');
Run Code Online (Sandbox Code Playgroud)

这是单元格内的结果:

first line \n second line
Run Code Online (Sandbox Code Playgroud)

有人知道如何插入多行单元格吗?我必须使用哪个字符?

javascript node.js excel4node

2
推荐指数
1
解决办法
688
查看次数

如何遍历行并在节点 js 中的 excel 中打印对象值?

我有一个对象数组,如下所示:

[
    {   "FirstName": "John", 
        "LastName": "Parker", 
        "Age": "23", 
        "Cat": "23g",
        "SOP": "Active"
    },
    {   "FirstName": "Rose", 
        "LastName": "Jackson", 
        "Age": "44", 
        "Cat": "44g",
        "SOP": "InActive"
    }
]
Run Code Online (Sandbox Code Playgroud)

我正在使用excel4node创建对象的数据并将其写入 excel

async generateExclReport(req, res) {
        try {

            var wb = new xl.Workbook();

            // Add Worksheets to the workbook
            var ws = wb.addWorksheet('Report');

            ws.cell(1, 1).string('FirstName');
            ws.cell(1, 2).string('LastName');
            ws.cell(1, 3).string('Age');
            ws.cell(1, 4).string('Cat');
            ws.cell(1, 5).string('SOP');


            var fileName = "Report" + Date.now().toString() + '.xlsx';

            res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
            res.setHeader("Content-Disposition", "attachment; filename=" + fileName);
            wb.write(fileName, res);
        } …
Run Code Online (Sandbox Code Playgroud)

excel node.js express excel4node

1
推荐指数
1
解决办法
2593
查看次数

标签 统计

excel4node ×4

node.js ×4

excel ×2

express ×1

javascript ×1