Export bitmap image from Excel cells

2019-08-03 07:18发布

I have created an .xlsx file using the OpenXML framework and I am embedding it into a PowerPoint slide (also created using OpenXML) the problem is that I need a placeholder image for the OleObject the Excel sits in on the PowerPoint slide - i can use a standard placeholder, but this looks bad.

So I was hoping (most likely using Interop) to find a way of opening the .xlsx file and exporting the relevant cells as a bitmap (.jpg or .png ideally) which I can then feed into my OleObject as the placeholder image.

I came across this: http://csharp.net-informations.com/excel/csharp-excel-chart-export.htm

Which does what I am trying to do, but on a Chart object, so if someone knows a way to export cells (ideally a selection, rather than the whole worksheet) to a bitmap, that would be great!

Thanks,

Mike

1条回答
倾城 Initia
2楼-- · 2019-08-03 07:55

An Excel Range object has a CopyPicture method that does what you're looking for.

JP has a VBA example posted that you should give you what you need.

http://www.jpsoftwaretech.com/export-excel-range-to-a-picture-file/

查看更多
登录 后发表回答