找回密码
 立即注册

QQ登录

只需一步,快速开始

y.a.n

注册会员

2

主题

2

帖子

10

积分

注册会员

积分
10
  • 42

    金币

  • 2

    主题

  • 2

    帖子

最新发帖
y.a.n
注册会员   /  发表于:2021-8-31 17:26  /   查看:2050  /  回复:1
1金币
本帖最后由 y.a.n 于 2021-8-31 17:28 编辑

const GC:any = require('./spreadJs/gc.spread.sheets.all.11.2.2.min.js')
import { IO } from "@grapecity/spread-excelio";
const TestContent = (props:any) => {
const spreadRef = useRef<any>({})


useEffect ( () =>{
        const createSpreadSheet = async() => {
            if (typeof GC === 'undefined') {
              loadSpread();
            } else {
                spreadRef.current = new GC.Spread.Sheets.Workbook(spreadRef.current, {
                sheetCount: 2,
                newTabVisible: false,
                tabEditable: false,
              });
                let excelIO = new IO();
                const resData = await getReportExcelData({  // 获取接口数据
                    repCode:"JA0020",
                    orgId:"10",
                    repDate:"202107"
                });
                // 测试已拿到
                excelIO.open(resData, (json: any)=> {

                let workbookObj = json.sheets;
                // console.log("!!!!!!!!workbookObj",workbookObj);
                if(workbookObj){
                   setExcelData(workbookObj[Object.keys(workbookObj)[0]].data.dataTable);
                   excelDataRef.current = workbookObj[Object.keys(workbookObj)[0]].data.dataTable;
                }
                spreadRef.current.fromJSON(json);
                // spreadRef.current.options.backColor = 'aliceblue';

            }, function (e:any) {
                // process error
                alert(e.errorMessage);
            }, {});

            }
          };
        createSpreadSheet()
    },[])

return (

        <div style={hostStyle}>

            <div ref={e => spreadRef.current = e} className={styles.statementBox}>
            </div>
        </div>
    );





}




最佳答案

查看完整内容

您好, 从代码无法直接定位问题原因。 您获取 json 后,请将json另存为json文件, 在下方地址导入测试,看能否加载。 https://demo.grapecity.com.cn/SpreadJS/WebDesigner/index.html 如果仍无法加载,表示获取的json有问题, 您参考下方文章,看问题能否解决。 https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=37389

1 个回复

倒序浏览
最佳答案
最佳答案
Lynn.Dou讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-8-31 17:26:07
来自 2#
本帖最后由 Lynn.Dou 于 2021-8-31 18:27 编辑

您好,
从代码无法直接定位问题原因。
您获取 json 后,请将json另存为json文件,
   
在下方地址导入测试,看能否加载。
https://demo.grapecity.com.cn/SpreadJS/WebDesigner/index.html image.png157859496.png

如果仍无法加载,表示获取的json有问题,
您参考下方文章,看问题能否解决。
https://gcdn.grapecity.com.cn/fo ... hread&tid=37389
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部