如何在Excel.js中将具有不同数据集的多个表添加到同一工作表 [英] How to add multiple table with different data-set to the same sheet in exceljs

查看:329
本文介绍了如何在Excel.js中将具有不同数据集的多个表添加到同一工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,用于导出具有数据(JSON格式)的Excel文件.我可以为一个表做一个表,但是我想在同一个Excel工作表中有多个表(不同的datasset-JSON),并按如下所示导出该文件.

I have a button to export a excel file with the data(JSON format). I can able to do for one table but I want to have multiple tables(different datasset-JSON) in the same excel sheet and export that file as shown below.

我在节点环境中将exceljs和文件保存器与angular2一起使用.请以正确的方法指导我.预先感谢.

I'm using exceljs and file-saver with angular2 in node environment. please guide me with the right approach. Thanks in advance.

推荐答案

我有一个类似的问题并得到了答案-

I had a similar question and got the answer to it - Angular xlsx - multiple json to sheet

您需要区分大小写,因为您需要处理合并单元格,但是可以选择使用空道具创建第二个json,例如:

Your case is a bit different as you need to play around with merging cells, but there is the option to create the second json with empty props like:

let obj = { Name: 'Johnson', '': '', Age: 32, '', '' } 

不美观也不理想,因为它仅适合列的格式. 但是,网上很少有合并的想法- https://github.com/SheetJS/js-xlsx/issues/416

Not pretty and not ideal as it will only fit the format of the columns. However there are few ideas on the web for merges - https://github.com/SheetJS/js-xlsx/issues/416

希望这会有所帮助.

这篇关于如何在Excel.js中将具有不同数据集的多个表添加到同一工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆