We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Excel charts to PowerPoint slides

Hi

I have charts created in Excel that I want to copy to PowerPoint slides. What is the best way to do this?

I used to do this...

Range.CopyPicture(xlPictureAppearance, xlCopyPictureFormat);

Slide.Shapes.PasteSpecial(ppPasteEnhancedMetaDataFile, False, "", 0, "", False);

Please help

Jason

I can create a jpg of the whole worksheet and then add that image to the ppt file. But I don’t want the whole worksheet instead I want the range of cells that the chart sits on.

Hi,

Thanks for your posting and considering Aspose.Cells.

You can export your chart as image. Also you can export your range of cells into the image.

Please see the following documentation articles for your reference.

( https://docs.aspose.com/display/cellsnet/Export+Range+of+Cells+in+a+Worksheet+to+Image )
( https://docs.aspose.com/display/cellsnet/Convert+Chart+to+Images )

Thanks Shakeel

Really appreciate your help.

It's sort of working but I have a couple of issues...

1) I am setting

Worksheet.PageSetup.PrintArea = "B8:N36";

But it trims the last two columns off the image.

2) The image of the range of cells contains extra information like who created the workbook, extra dates, last modified and other things I don't want to see. I am sure there is a way of turning this off...

Jason

Okay

I set options.OnlyArea = true

This helped remove the unwanted text and gave me an extra column. But I'm still one short.

I have experimented with

Worksheet.PageSetup.PrintArea = "B8:H36" and I got the full set of columns...

Then "B8:I36"..."B8:J36"...all the way to "B8:M36" and they all worked fine.

But as soon as I go to "B8:N36" it removes the last column!

Hi,

Thanks for your valuable feedback and using Aspose.Cells.

Please provide us your source excel file and let us know your sheet name. We will experiment with it and provide you a sample code to achieve your desired results. Thanks for your cooperation.

Late last night I stumbled on a solution. But there may be a better one.

Bitmap bitmap = SheetRender.ToImage(0);

Above is what I was using ands it was getting cut off. But when I did...

Bitmap bitMap2 = SheetRender.ToImage(1);

There was the missing part of the image.

Is there any way of "gluing" these together in one file?

Hi Jason,


Please note, the SheetRender.ToImage takes a parameter of type integer as number of the printing page to be converted in image format, therefore when you pass 0 to ToImage method, you are directing the API to render the first printing page of the specified worksheet, and 1 corresponds to second printing page. I believe you wish to render all contents of the worksheet to single image. If yes, please use the ImageOrPrintOptions.OnePagePerSheet property as demonstrated below.

C#

var book = new Workbook(dir + “sample.xlsx”);
ImageOrPrintOptions ops = new ImageOrPrintOptions();
ops.OnePagePerSheet = true;
var render = new SheetRender(book.Worksheets[0], ops);
var bitmap = render.ToImage(0);
bitmap.Save(dir + “output.png”);

Hi

I will take a look at this.

What I want is to render to image a range of cells that overlap these pages.

I think your code will render the whole sheet.

It works!

Thanks for all your help.

Hi Jason,


Thank you for the confirmation on provided solution. Please feel free to contact us back in case you need our further assistance with Aspose APIs.