在节点 js 的 'xlsx-populate' 模块中将单元格合并在一起
Merge cells together in 'xlsx-populate' module for node js
我正在使用 xlsx-populate 模块制作 excel 文件,但我需要将一些行和列合并在一起并为此设置值。有人帮我制作这个 excel 文件吗?
例如合并 merge(A1, C3)
并将我的值添加到大行中。
下面是使用 xlsl-populate 模块创建合并单元格的示例。
我们创建了 2 组合并单元格,我认为这可以让您很好地了解如何进行:
const XlsxPopulate = require('xlsx-populate');
async function testMerge() {
let workbook = await XlsxPopulate.fromBlankAsync();
// Create a range of merged cells.
const range = workbook.sheet(0).range("A1:C3");
range.value("We are merged!!");
range.style({horizontalAlignment: "center", verticalAlignment: "center", })
range.merged(true);
// Create another range of merged cells.
const range2 = workbook.sheet(0).range("D1:F3");
range2.value("We are also merged!!");
range2.style({horizontalAlignment: "center", verticalAlignment: "center", })
range2.merged(true);
// Write to the output file.
await workbook.toFileAsync("./out.xlsx");
}
testMerge();
我正在使用 xlsx-populate 模块制作 excel 文件,但我需要将一些行和列合并在一起并为此设置值。有人帮我制作这个 excel 文件吗?
例如合并 merge(A1, C3)
并将我的值添加到大行中。
下面是使用 xlsl-populate 模块创建合并单元格的示例。
我们创建了 2 组合并单元格,我认为这可以让您很好地了解如何进行:
const XlsxPopulate = require('xlsx-populate');
async function testMerge() {
let workbook = await XlsxPopulate.fromBlankAsync();
// Create a range of merged cells.
const range = workbook.sheet(0).range("A1:C3");
range.value("We are merged!!");
range.style({horizontalAlignment: "center", verticalAlignment: "center", })
range.merged(true);
// Create another range of merged cells.
const range2 = workbook.sheet(0).range("D1:F3");
range2.value("We are also merged!!");
range2.style({horizontalAlignment: "center", verticalAlignment: "center", })
range2.merged(true);
// Write to the output file.
await workbook.toFileAsync("./out.xlsx");
}
testMerge();