Javascript Office.js Excel Online>;chart.getImage()错误

Javascript Office.js Excel Online>;chart.getImage()错误,javascript,excel,office-js,Javascript,Excel,Office Js,摘要:某些图表(当不是第一个图表时)在Excel Online中与chart.getImage()一起导致错误 使用场景:我使用chart.getImage()获取base64编码的图像,这样可以通过编程将图表插入Word/PowerPoint文档中。它用于Excel到Word文档自动化外接程序中 Excel for Windows或Mac从不存在任何问题。只发行 在Excel Online中发生 仅在某些图表类型中发生错误, 例如帕累托图、漏斗图和具有一些自定义功能的常用图表 错误是不一致的

摘要:某些图表(当不是第一个图表时)在Excel Online中与chart.getImage()一起导致错误

使用场景:我使用
chart.getImage()
获取base64编码的图像,这样可以通过编程将图表插入Word/PowerPoint文档中。它用于Excel到Word文档自动化外接程序中

  • Excel for Windows或Mac从不存在任何问题。只发行 在Excel Online中发生
  • 仅在某些图表类型中发生错误, 例如帕累托图、漏斗图和具有一些自定义功能的常用图表
  • 错误是不一致的:不能总是预测它,相同的图表,相同的 代码有时工作正常
  • 图表的位置似乎很重要。弗斯特 添加的图表似乎从不产生错误
  • 错误类型不一致。是:
    不支持操作
    一般异常
    ,或
    值未加载
  • 方法详情如下:
这是一个可以修复的bug吗?是否有已知的解决方法

可重现错误的简化代码(在脚本实验室中):

示例错误返回(我在这个
getImage()
问题中遇到了3种类型):


这可能是一个bug,团队正在修复它。将在修复可用时更新此答案。 谢谢
Juan。

由于这似乎是Excel JS API的一个问题,我已将其作为一个问题记录在OfficeDev/office JS GitHub repo(产品团队的哪些成员监控)中:。如果您订阅了该问题,当问题更新和/或产品团队需要您提供更多信息时,您将收到通知。
function run() {
  Excel.run(function(ctx) {
    var chart = ctx.workbook.worksheets
      .getItem("Sheet1")
      .charts.getItem("Chart3");
    var image = chart.getImage();
    return ctx.sync().then(function() {
      var data = image.value;
      console.log("Success: " + data.substr(0, 100));
    });
  }).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
      console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
  });
}
{
  "code": "UnsupportedOperation",
  "message": "This operation is not implemented.",
  "errorLocation": "Chart.getImage",
  "statement": "item.getImage(undefined, undefined, undefined);",
  "surroundingStatements": [
    "var workbook=context.workbook;",
    "var worksheets=workbook.worksheets;",
    "var worksheet=worksheets.getItem(\"Sheet1\");",
    "var charts=worksheet.charts;",
    "var item=charts.getItem(\"rpt_Chart3\");",
    "// >>>>>",
    "item.getImage(undefined, undefined, undefined);",
    "// <<<<<"
  ]
}
{
  "name": "OfficeExtension.Error",
  "code": "GeneralException",
  "message": "An internal error has occurred.",
  "traceMessages": [],
  "innerError": null,
  "debugInfo": {
    "code": "GeneralException",
    "message": "An internal error has occurred."
  }
}
{
  "name": "OfficeExtension.Error",
  "code": "ValueNotLoaded",
  "message":
    "The value of the result object has not been loaded yet. Before reading the value property, call \"context.sync()\" on the associated request context.",
  "traceMessages": [],
  "innerError": null,
  "debugInfo": {
    "code": "ValueNotLoaded",
    "message":
      "The value of the result object has not been loaded yet. Before reading the value property, call \"context.sync()\" on the associated request context.",
    "errorLocation": "clientResult.value"
  }
}