admin管理员组文章数量:1287993
plz help me.
My flow:
Using a file Tempate -> Code (Exceljs) -> output New file
Template file:
Center on page:
- horizontally : Checked
- vertically : Checked
Source coder:
worksheet.pageSetup.horizontalCentered = true
worksheet.pageSetup.verticalCentered = true
BUT File output:
- horizontal : uncheck
- vertical : uncheck
plz help me.
My flow:
Using a file Tempate -> Code (Exceljs) -> output New file
Template file:
Center on page:
- horizontally : Checked
- vertically : Checked
Source coder:
worksheet.pageSetup.horizontalCentered = true
worksheet.pageSetup.verticalCentered = true
BUT File output:
- horizontal : uncheck
- vertical : uncheck
3 Answers
Reset to default 4Please tell me if this worked well or not.
// DO NOT SET ANOTHER pageSetup AFTER DECLARING THIS!
var worksheet = workbook.addWorksheet('sheet', {
pageSetup: {
horizontalCentered: true,
verticalCentered: true,
paperSize: 9,
orientation: 'portrait',
margins: {
left: 0.3149606, right: 0.3149606,
top: 0.3543307, bottom: 0.3543307,
header: 0.3149606, footer: 0.3149606
}
}
})
Please check below link and code.
https://github./Great-hijack/react-excel/blob/master/frontend/src/utils/export2excel.js
var sheet1 = workbook.addWorksheet('Download', { properties: { tabColor: { argb: '6B5B95' }, defaultRowHeight: 39 } });
// Page Setup for sheet1
sheet1.pageSetup.paperSize = 13; // B5 (JIS)
sheet1.pageSetup.orientation = 'landscape';
sheet1.pageSetup.horizontalCentered = true;
sheet1.pageSetup.verticalCentered = true;
sheet1.pageSetup.margins = {
left: 0.7, right: 0.7,
top: 0.3, bottom: 0.3,
header: 0.3, footer: 0.3
};
I hope this is helpful for you.
Can you show the code, So that it will be easy to figure the problem.
But, While creating worksheet have you specified,
useStyles: true
var workbook = new Excel.stream.xlsx.WorkbookWriter({
filename: filename.xlsx,
useStyles: true
});
See below code, If it could be of any help -
var worksheet = workbook.addWorksheet(date);
worksheet.columns = [{
header: 'Col-1',
key: 'col_1',
width: 5
},
{
header: 'Col-2',
key: 'col_2',
width: 5
},
];
for (let i in data) {
worksheet.addRow(data[i]);
}
// set style for each cell
worksheet.eachRow(function (Row, rowNum) {
Row.eachCell(function (Cell, cellNum) {
if (rowNum == 1) {
Cell.alignment = {
vertical: 'center',
horizontal: 'center'
}
}else{
Cell.alignment = {
vertical: 'middle',
horizontal: 'middle'
}
}
})
})
workbook.mit()
.then(function () {
console.log('Excel export plete!');
process.exit()
});
本文标签: javascriptExcelJS node horizontalCentered amp verticalCentered in page not workingStack Overflow
版权声明:本文标题:javascript - ExcelJS node: horizontalCentered & verticalCentered in page not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741333645a2372911.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论