OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

Excel chart.getImage() still works, but now ignores resizing parameters #3980

Closed AndrewHallAP closed 2 months ago

AndrewHallAP commented 8 months ago

chart.getImage() has worked fine for several years. But just recently, it started to ignore the optional parameters, so the image can no longer be re-sized. chart.getImage() without the parameters still works fine. https://learn.microsoft.com/en-us/javascript/api/excel/excel.chart?view=excel-js-preview#excel-excel-chart-getimage-member(2)

Your Environment

Expected behavior

I expect the optional parameters to re-size the image (as it previously did).

Current behavior

It now ignores the optional parameters.

Steps to reproduce

  1. Add a chart/graph to Excel
  2. Paste the Script and HTML below into Script Lab
  3. Click run. Notice the 2 displayed PNG charts are the same size.

Link to live example(s)

$("#run").click(() => tryCatch(setup));
async function setup() {
  await Excel.run(async (context) => {
    let chart = context.workbook.worksheets.getActiveWorksheet().charts.getItemAt(0);
    let image1 = chart.getImage();
    let image2 = chart.getImage(50,50,null);  //it ignores the optional width, height, fit parameters (any combination). The parameters worked great for several years, until recently.
    await context.sync();
    var srcImage1 = "data:image/png;base64, " + image1.value;
    var srcImage2 = "data:image/png;base64, " + image2.value;
    $("#image1").attr("src", srcImage1);
    $("#image2").attr("src", srcImage2);
  });
}
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    console.error(error);
  }
}
<p class="ms-font-m">Shows the 2 chart images below</p>
<button id="run" class="ms-Button">
    <span class="ms-Button-label">Run</span>
</button><br/>
<img id="image1" src="" alt="" />
<img id="image2" src="" alt="" />

Context

Many customers use the getImage() to transfer chart images from Excel to Word or PowerPoint using the Excel-to-Word Document Automation Add-in. And some want to be able to re-size the images (improve resolution).

image

donlvMSFT commented 8 months ago

Thanks @AndrewHallAP for reporting this. I could reproduce, and created internal task 8653788 to track. Will update here for progress.

Andrew-AnalysisPlace commented 6 months ago

Some of our customers still complain that this isn't working and it is not working yet for me. Has the fix been released to production or do you know when it will be?

zhenhuangMSFT commented 6 months ago

Hi @Andrew-AnalysisPlace, sorry for the confusion. This work is still under progress. Due to some unforeseen circumstances, the might be delayed. Please allow some patience. Thanks for your understanding!

SiruiSun-MSFT commented 2 months ago

Hi @Andrew-AnalysisPlace, Thanks for you waiting here! We are excited to share with you that this fix has been rolled out to Prod on version 16.0.17628. Please update to the version above it and have a try! Thanks for your reports again!