找回密码
 立即注册

QQ登录

只需一步,快速开始

sheroting

注册会员

2

主题

7

帖子

21

积分

注册会员

积分
21
  • 65

    金币

  • 2

    主题

  • 7

    帖子

最新发帖
sheroting
注册会员   /  发表于:2024-6-28 11:59  /   查看:1153  /  回复:10
本帖最后由 sheroting 于 2024-6-28 14:57 编辑

后端返回的excel文件流,前端渲染到页面上,excel是带折叠功能的,但是页面上折叠无法展开,已设置:
sheet.options.protectionOptions.allowOutlineColumns = true;
sheet.options.protectionOptions.allowOutlineRows = true;
sheet.options.isProtected = true;
求解决方案

10 个回复

倒序浏览
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2024-7-5 15:21:20
来自 8#
请参考。

image.png238435973.png
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2024-6-28 17:42:47
沙发
您好,代码中具体是怎么设置的?

文件在导入后,spread对象会被重置,导入前的一些属性和设置会被覆盖掉,可以先排查看看是不是这个问题导致的。

如果不是,可以提供一个简单的可以复现此问题的Demo,这边帮您调研看看。
回复 使用道具 举报
sheroting
注册会员   /  发表于:2024-7-3 14:40:09
板凳
本帖最后由 sheroting 于 2024-7-3 14:42 编辑
Joestar.Xu 发表于 2024-6-28 17:42
您好,代码中具体是怎么设置的?

文件在导入后,spread对象会被重置,导入前的一些属性和设置会被覆盖掉 ...
  1. let excelIO = new ExcelIO.IO();
  2.         let blob = new Blob([res.data], {
  3.           type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  4.         });
  5.         // 将 Blob 对象转换为 File 对象
  6.         let file = new File([blob], 'example.xlsx', {
  7.           type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  8.         });
  9.         excelIO.open(
  10.           file,
  11.           (json) => {
  12.             spread.fromJSON(json);
  13.           },
  14.           (e) => {
  15.             console.log(e);
  16.           },
  17.         );
复制代码
其中,res.data是从后端获取的文件流,渲染到页面后折叠的列无法展开了,但是从工作表中直接用spreadjs导出的excel,展开功能是正常的
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2024-7-3 17:44:43
地板
您好,和您确认一下,您用的是V17版本吧。

ExcelIO在V16就已经停止做新功能了,建议您更换为IO包来进行导入导出的操作。

请参考:https://demo.grapecity.com.cn/sp ... mat/overview/purejs
回复 使用道具 举报
sheroting
注册会员   /  发表于:2024-7-4 08:38:34
5#
Joestar.Xu 发表于 2024-7-3 17:44
您好,和您确认一下,您用的是V17版本吧。

ExcelIO在V16就已经停止做新功能了,建议您更换为IO包来进行 ...

是V17版本,我们不是页面有导入按钮操作的导入,而且从后端读取excel文件流渲染到工作表上的,请给出具体代码示例(带折叠的excel)
回复 使用道具 举报
Joestar.XuSpreadJS 开发认证
超级版主   /  发表于:2024-7-4 17:41:41
6#
您好,以下是我的测试代码:

image.png433608092.png

image.png443970946.png

以下是测试结果:

动画 (0).gif265687560.png
回复 使用道具 举报
sheroting
注册会员   /  发表于:2024-7-5 08:32:56
7#
Joestar.Xu 发表于 2024-7-4 17:41
您好,以下是我的测试代码:

麻烦看下我的描述,不是手动导入,是从后端返回的文件流加载到工作表里
回复 使用道具 举报
shero
注册会员   /  发表于:2024-7-5 18:11:53
9#

可以了,非常感谢
回复 使用道具 举报
shero
注册会员   /  发表于:2024-7-5 18:14:49
10#
shero 发表于 2024-7-5 18:11
可以了,非常感谢
  1. let excelIO = new ExcelIO.IO();
  2.     let json = spread.toJSON();
  3.     let changeFile = null;
  4.     excelIO.save(json, async (blob) => {
  5.       changeFile = new File([blob], 'example.xlsx', {
  6.         type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7.       });

  8.       let formData = new FormData();
  9.       formData.append('file', changeFile);
  10. }  
复制代码

还有个问题,我们有个保存提交整个excel的操作,我是这样获取的File,请问要如何优化一下
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部