通过 Microsoft Graph 在 Excel 中显示图表图像Display a chart image in Excel with Microsoft Graph

在执行 GET 操作以检索图表图像时,Excel API 将返回 base-64 字符串形式的图像。When you perform a GET operation to retrieve a chart image, the Excel API returns the image as a base-64 string.

可以在 HTML 图像标记内显示 base-64 字符串:<img src="data:image/png;base64,{base-64 chart image string}/>You can display the base-64 string inside an HTML image tag: <img src="data:image/png;base64,{base-64 chart image string}/>.

对于默认行为,请使用 Image(width=0,height=0,fittingMode='fit')For default behavior, use Image(width=0,height=0,fittingMode='fit'). 下面的示例展示了使用默认参数返回的图表图像。Here is an example of a chart image returned with the default parameters.

使用默认高度和宽度的 Excel 图表图像。

若要自定义图像的显示方式,请指定高度、宽度和调整模式。If you want to customize the display of the image, specify a height, width, and a fitting mode. 下面展示了使用 Image(width=500,height=500,fittingMode='Fill') 参数检索的同一个图表图像。Here is what the same chart image looks like if you retrieve it with these parameters: Image(width=500,height=500,fittingMode='Fill').

另请参阅See also