Office.js | Excel加载项| office365-“处理呈现在电子表格中的数据时处理请求的错误时出错

问题描述

我正在使用office.js创建Excel加载项。我确实需要在任务窗格按钮单击上进行Ajax API调用,并将API响应呈现到excel单元格中。 API响应包含数千个对象,我正在考虑将其作为如下行:

dataApiResponse = [{AccName: "ABC",ID: 173,Name: "FDI",... contains 20 attributes in single object},.... contains upto 5000 objects in array]

使用以下方法将以上响应数组呈现为excel。 “ outputHeaders”是已在excel单元上呈现的Header数组,并希望在每个标头下方呈现api响应。

    const ExcelGetData = () => {
    // below is the outputData array contains upto 10000 or 15000 objects and each object represent rows for sheet and each object contains 
    // upto 20 attributs means in sheet the column id would be from 'A - T'
    const outputData = [{AccName: "ABC",.... contains upto 10000 objects in array];
    
    let range;
    let end = 0;
    let start = 2;
    let newEndRange;
    let newStartRange;
    const endRow = start + outputData.length;
    
    Excel.run(context => {
        const app = context.workbook.application;
        const sheet = context.workbook.worksheets.getItem('sheet1');
        return context.sync().then(() => {
            app.suspendApiCalculationUntilNextSync();
            outputData
                .map(() => outputData.splice(0,500))
                .map(response => {
                    newStartRange = `A${start}`;
                    end = start + 500 - 1;
                    if (end < endRow) {
                        start = end + 1;
                        newEndRange = `T${end}`;
                        range = sheet.getRange(
                            `${newStartRange}:${newEndRange}`,);
                    } else {
                        newEndRange = `T${endRow}`;
                        range = sheet.getRange(
                            `${newStartRange}:${newEndRange}`,);
                    }
                    range.values = response;
                    range.format.autofitColumns();
                    context.sync();
                    return null;
                });
            return context.sync();
        });
    }).catch(err => {
        console.log(`error occured${err}`);
    });
};

在低于excel API的Office365的Web版本上,出现以下错误:

https://excel.officeapps.live.com/x/_vti_bin/EwaInternalWebService.json/ExecuteRichApiRequest?waccluster=PUS1

错误:

{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}

enter image description here

还检查了enter link description here问题,并了解excel网络有有效载荷大小限制。您能帮忙解决此问题还是我如何拆分此操作? 由于此问题我们的交付项被阻止,这将为您带来全面的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...