XLSX-生成报告 - 角度
我对自己想要的报告有问题,如下所示:
[
{
// ...
"forma_pago_cliente": [
{
"metodo": "product 1",
"total": "12"
},
{
"metodo": "product 2",
"total": "45"
}
],
// ...
];
我得到的结果如下: 结果
和我的预期结果: 在此处输入图像描述
我的代码如下。
const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json, {
cellDates: true,
});
const workbook: XLSX.WorkBook = {
Sheets: {
tiquetes_vuelos: worksheet,
},
SheetNames: [
'tiquetes_vuelos',
],
};
const excelBuffer: any = XLSX.write(workbook, {
bookType: 'xlsx',
type: 'array',
});
this.saveAsExcel(excelBuffer, excelFileName);
我试图获得预期的结果,但我无法做到,我一直在解决这个问题超过2天。有什么建议吗?
I am having a problem with the report I want, delivering the JSON as follows:
[
{
// ...
"forma_pago_cliente": [
{
"metodo": "product 1",
"total": "12"
},
{
"metodo": "product 2",
"total": "45"
}
],
// ...
];
The result I get is as follows:
Result
And my expected result:
enter image description here
My code is as follows.
const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json, {
cellDates: true,
});
const workbook: XLSX.WorkBook = {
Sheets: {
tiquetes_vuelos: worksheet,
},
SheetNames: [
'tiquetes_vuelos',
],
};
const excelBuffer: any = XLSX.write(workbook, {
bookType: 'xlsx',
type: 'array',
});
this.saveAsExcel(excelBuffer, excelFileName);
I am trying to get the expected result but I have not been able to, I have been struggling for more than 2 days with this problem. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要将
forma_pago_cliente
对象弄平以在Excel表中表示。将下面的对象转换为
喜欢,
You may need to flatten the
forma_pago_cliente
object in order to represent it in excel sheet.Convert the below object to
like this,