找回密码
 立即注册

QQ登录

只需一步,快速开始

Quber

金牌服务用户

16

主题

50

帖子

296

积分

金牌服务用户

积分
296
QQ
Quber
金牌服务用户   /  发表于:2023-12-6 11:47  /   查看:1794  /  回复:3
1、版本号
版本为16.2.6,Vue3。


2、问题描述
正确的表单效果样式如下图所示:
image.png639445190.png

然后我使用sheet.toJSON()方法将表单的内容导出为JSON字符串存储到后台数据库。

接下来我使用sheet.fromJSON(JSON对象)方法将上述导出来的JSON对象还原表单,结果发现样式全部丢失了,如下图所示:
image.png517840270.png

3、导出的JSON字符串
其中sheet.toJSON()方法导出的JSON字符串如下所示:

  1. {"name":"检测报告-表头","isSelected":true,"rowCount":17,"columnCount":12,"activeRow":16,"activeCol":11,"visible":1,"theme":{"name":"Office","themeColor":{"name":"Office","background1":{"a":255,"r":255,"g":255,"b":255},"background2":{"a":255,"r":231,"g":230,"b":230},"text1":{"a":255,"r":0,"g":0,"b":0},"text2":{"a":255,"r":68,"g":84,"b":106},"accent1":{"a":255,"r":68,"g":114,"b":196},"accent2":{"a":255,"r":237,"g":125,"b":49},"accent3":{"a":255,"r":165,"g":165,"b":165},"accent4":{"a":255,"r":255,"g":192,"b":0},"accent5":{"a":255,"r":91,"g":155,"b":213},"accent6":{"a":255,"r":112,"g":173,"b":71},"hyperlink":{"a":255,"r":5,"g":99,"b":193},"followedHyperlink":{"a":255,"r":149,"g":79,"b":114}},"headingFont":"'Calibri Light'","bodyFont":"Calibri","font":{"headerFont":"'Calibri Light'","bodyFont":"Calibri"}},"data":{"dataTable":{"0":{"0":{"value":"水泥混凝土立方体抗压强度试验检测报告","style":"__builtInStyle6"},"1":{"style":"__builtInStyle6"},"2":{"style":"__builtInStyle6"},"3":{"style":"__builtInStyle6"},"4":{"style":"__builtInStyle6"},"5":{"style":"__builtInStyle6"},"6":{"style":"__builtInStyle6"},"7":{"style":"__builtInStyle6"},"8":{"style":"__builtInStyle6"},"9":{"style":"__builtInStyle6"},"10":{"style":"__builtInStyle6"},"11":{"style":"__builtInStyle6"}},"1":{"0":{"value":"检测单位名称(专用章):","style":"__builtInStyle5"},"1":{"style":"__builtInStyle5"},"2":{"value":"四川川桥工程试验检测有限责任公司乐山至西昌高速公路马边至昭觉段S2合同段第二工地试验室","style":"__builtInStyle7"},"3":{"style":"__builtInStyle7"},"4":{"style":"__builtInStyle7"},"5":{"style":"__builtInStyle7"},"6":{"style":"__builtInStyle7"},"7":{"style":"__builtInStyle7"},"8":{"value":"报告编号:","style":"__builtInStyle2"},"9":{"value":"BG-202310(S2-2)-TYH-0002","style":"__builtInStyle5"},"10":{"style":"__builtInStyle5"},"11":{"style":"__builtInStyle5"}},"2":{"0":{"value":"施工/委托单位","style":"__builtInStyle14"},"1":{"style":"__builtInStyle8"},"2":{"value":"四川省交通建设集团股份有限公司","style":"__builtInStyle9"},"3":{"style":"__builtInStyle9"},"4":{"style":"__builtInStyle9"},"5":{"style":"__builtInStyle9"},"6":{"value":"工程名称","style":"__builtInStyle8"},"7":{"style":"__builtInStyle8"},"8":{"value":"乐山至西昌高速公路马边至昭觉段","style":"__builtInStyle9"},"9":{"style":"__builtInStyle9"},"10":{"style":"__builtInStyle9"},"11":{"style":"__builtInStyle10"}},"3":{"0":{"value":"工程部位/用途","style":"__builtInStyle15"},"1":{"style":"__builtInStyle13"},"2":{"value":"拉一木隧道右线K123+870~K123+880二次衬砌拱墙","style":"__builtInStyle11"},"3":{"style":"__builtInStyle11"},"4":{"style":"__builtInStyle11"},"5":{"style":"__builtInStyle11"},"6":{"style":"__builtInStyle11"},"7":{"style":"__builtInStyle11"},"8":{"style":"__builtInStyle11"},"9":{"style":"__builtInStyle11"},"10":{"style":"__builtInStyle11"},"11":{"style":"__builtInStyle12"}},"4":{"0":{"value":"样品信息","style":"__builtInStyle15"},"1":{"style":"__builtInStyle13"},"2":{"value":"样品名称:水泥混凝土试件 样品编号:YP-202310(S2-2)-TYH-0002 样品状态:表面平整、无蜂窝麻面、无缺损","style":"__builtInStyle11"},"3":{"style":"__builtInStyle11"},"4":{"style":"__builtInStyle11"},"5":{"style":"__builtInStyle11"},"6":{"style":"__builtInStyle11"},"7":{"style":"__builtInStyle11"},"8":{"style":"__builtInStyle11"},"9":{"style":"__builtInStyle11"},"10":{"style":"__builtInStyle11"},"11":{"style":"__builtInStyle12"}},"5":{"0":{"value":"检测依据","style":"__builtInStyle15"},"1":{"style":"__builtInStyle13"},"2":{"value":"JTG 3420-2020","style":"__builtInStyle11"},"3":{"style":"__builtInStyle11"},"4":{"style":"__builtInStyle11"},"5":{"style":"__builtInStyle11"},"6":{"value":"判定依据","style":"__builtInStyle13"},"7":{"style":"__builtInStyle13"},"8":{"value":"设计文件","style":"__builtInStyle11"},"9":{"style":"__builtInStyle11"},"10":{"style":"__builtInStyle11"},"11":{"style":"__builtInStyle12"}},"6":{"0":{"value":"主要仪器设备名称及编号","style":"__builtInStyle16"},"1":{"style":"__builtInStyle17"},"2":{"value":"游标卡尺(LX-8),微机电液伺服压力试验机(LX-146)","style":"__builtInStyle3"},"3":{"style":"__builtInStyle3"},"4":{"style":"__builtInStyle3"},"5":{"style":"__builtInStyle3"},"6":{"style":"__builtInStyle3"},"7":{"style":"__builtInStyle3"},"8":{"style":"__builtInStyle3"},"9":{"style":"__builtInStyle3"},"10":{"style":"__builtInStyle3"},"11":{"style":"__builtInStyle4"}},"7":{"0":{"style":"__builtInStyle1"},"1":{"style":"__builtInStyle1"}}},"defaultDataNode":{"style":{"backColor":null,"foreColor":"Text 1 0","vAlign":1,"font":"normal normal 14.6667px Calibri","themeFont":"Body","formatter":"General","borderLeft":null,"borderTop":null,"borderRight":null,"borderBottom":null,"locked":true,"textIndent":0,"wordWrap":false,"shrinkToFit":false,"textDecoration":0,"isVerticalText":false,"textOrientation":0}}},"rowHeaderData":{"defaultDataNode":{"style":{"themeFont":"Body"}}},"colHeaderData":{"defaultDataNode":{"style":{"themeFont":"Body"}}},"rows":[{"size":40},{"size":40},{"size":27},{"size":27},{"size":27},{"size":27},{"size":27}],"defaultData":{},"leftCellIndex":0,"topCellIndex":0,"spans":[{"row":6,"col":0,"rowCount":1,"colCount":2},{"row":2,"col":2,"rowCount":1,"colCount":4},{"row":6,"col":2,"rowCount":1,"colCount":10},{"row":1,"col":0,"rowCount":1,"colCount":2},{"row":0,"col":0,"rowCount":1,"colCount":12},{"row":1,"col":9,"rowCount":1,"colCount":3},{"row":1,"col":2,"rowCount":1,"colCount":6},{"row":2,"col":6,"rowCount":1,"colCount":2},{"row":2,"col":8,"rowCount":1,"colCount":4},{"row":3,"col":2,"rowCount":1,"colCount":10},{"row":4,"col":2,"rowCount":1,"colCount":10},{"row":5,"col":2,"rowCount":1,"colCount":4},{"row":5,"col":6,"rowCount":1,"colCount":2},{"row":5,"col":8,"rowCount":1,"colCount":4},{"row":2,"col":0,"rowCount":1,"colCount":2},{"row":3,"col":0,"rowCount":1,"colCount":2},{"row":4,"col":0,"rowCount":1,"colCount":2},{"row":5,"col":0,"rowCount":1,"colCount":2}],"selections":{"0":{"row":16,"col":11,"rowCount":1,"colCount":1},"length":1},"defaults":{"colHeaderRowHeight":20,"colWidth":64,"rowHeaderColWidth":40,"rowHeight":19,"_isExcelDefaultColumnWidth":true},"rowOutlines":{"items":[]},"columnOutlines":{"items":[]},"cellStates":{},"states":{},"outlineColumnOptions":{},"autoMergeRangeInfos":[]}
复制代码



请问sheet.toJSON()方法不支持导出样式吗?还是我没操作对呢?救急,救急,救急!!!




3 个回复

倒序浏览
Ellia.DuanSpreadJS 开发认证
超级版主   /  发表于:2023-12-6 14:54:11
沙发
本帖最后由 Ellia.Duan 于 2023-12-6 14:55 编辑

您好,一部分样式保存在Spread中,如果您对Spread进行toJSON和fromJSON发现样式没有丢失。
但是在sheet中,比如新建了一个样式,这个样式是保存在spread中,所以通过sheet.toJSON及fromJSON会造成样式丢失问题
如您json中的__builtInStyle1 ,是样式名称,具体的样式内容应该在Spread.toJSON导出的json中。
回复 使用道具 举报
Quber
金牌服务用户   /  发表于:2023-12-6 16:08:45
板凳
感谢,目前已处理,解决方案参见:https://gcdn.grapecity.com.cn/showtopic-199700-1-1.html
回复 使用道具 举报
Ellia.DuanSpreadJS 开发认证
超级版主   /  发表于:2023-12-6 16:34:31
地板
好的,那本贴就先结贴啦,有问题欢迎发新帖询问。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部