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

Free Support Forum - aspose.com

Creating multiple slides from excel

Dear Team,

We are trying to create the presentation from excel.

Case 1: When we have single page excel, we are getting the PPT in single slide - No issue.
Case 2: When we have multiple pages in excel, we are getting only one slide. Some of the rows are missing in the slide - Issue

My
requirement is to create number of slides equals to number of pages in
excel based on the page break or anything. Is it possible to solve this
using Aspose technology(Java)?

If the answer for the above question is, YES. Then my next requirement is getting the PPT with OLE.
Similarly, I’m able to create the presentation with OLE. When we have multiple pages, how can I achive the PPT with OLE.

Herewith I have attached the code which I have used to convert the excel into Presentation slide.

Thanks
Prabu R

Hi Prabu R,


I have observed your requirement of adding excel sheets as Ole frame inside presentation. I like to share that each Ole frame displays the selected excel worksheet area in slide. If your excel file has multiple sheets and you ought to display every sheet on a single slide then you need to add multiple Ole frames and you may have them on one slide or multiple slides. It depends on your representation. You need to use Aspose.Cells in conjunction with Aspose.Slides in order to set the desired excel sheet or even its desired area as ole frame on slide. I suggest you to please visit documentation link1 and documentation link 2 for your kind reference in this regard. In second link, you will find a sample code for selecting the desired worksheet and its area for display in Ole frame.

Many Thanks,

Dear Mudassir Fayyaz,

While trying the execute the documentation link2 which is shared by you, we are getting the error in the “workbookDesigner.setWorkbook(workbook);” line.

Error details:

Multiple markers at this line
- Syntax error on token “workbook”, VariableDeclaratorId expected after
this token
- Syntax error on token(s), misplaced construct(s)


Could you please help us to resolve this issue.

Regards
Prabu R


FYI.

We are using Aspose.cells.8.7.0 and Aspose.Slides.15.7.0

Regards
Prabu R

Hi Prabu R,


I suggest you to please try using Workbook object directly to load the excel file. Please visit this documentation link to serve the purpose on your end.

Many Thanks,

Hi Fayyaz,

Eventhough removing the WorkbookDesigner class, we are getting the error in the subsequent lines. Could you please share executable code with us. I have imported the neccessary jar files.

Ex:
//Setting Ole frame according to Row, Columns
AddOleFrame(slide, 0, 15, 0, 3, 0, 300, 1100, 0, 0, presentation, workbookDesigner, true, 0, 0);

Error details:
Multiple markers at this line
- slide cannot be resolved to a type
- Syntax error on tokens, delete
these tokens
- Return type for the method is
missing
- Syntax error on tokens, delete
these tokens

presentation.save(“AsposeTest_Ole.pptx”, SaveFormat.Pptx);

Error Details:
Multiple markers at this line
- Syntax error on token “.”, …
expected
- Syntax error on tokens, delete
these tokens

Regards
Prabu R

Hi Prabu R,


I have observed the comments shared by you and have created a sample code for your convenience. Can you please try using the suggested sample code on your end to serve the purpose as it is working fine on my end.

public static void testOleFrameadd() throws Exception
{

//Loading presentation with Ole framePresentation pres=new Presentation (“d:\Aspose Data\OleEmbed.pptx”);
Presentation pres=new Presentation ();

//Accessing slide with Ole frame
ISlide slide = pres.getSlides().get_Item(0);

//Reading object data in Workbook
com.aspose.cells.Workbook Wb;
Wb = new com.aspose.cells.Workbook(“C:\Presentations\Test.xlsx”);

//Setting active sheet
Wb.getWorksheets().setActiveSheetIndex(0);

//Saving worbook to stream and copying in byte array
ByteArrayOutputStream mstream = new ByteArrayOutputStream ();
Wb.save(mstream,com.aspose.cells.SaveFormat.XLSX);



//Add an Ole Object Frame shape
IOleObjectFrame oof = slide.getShapes().addOleObjectFrame((float)0,(float) 0, (float)pres.getSlideSize().getSize().getWidth(),(float) pres.getSlideSize().getSize().getHeight (), “Excel.Sheet.12”, mstream.toByteArray());

pres.save(“C:\Presentations\OleEmbed.pptx”, SaveFormat.Pptx);

}

Many Thanks,

Dear Fayyaz,

When we are using single page excel, it’s working fine. But when we are having more than one page excel sheet we can’t have whole content in presentation that whatever we are having in Excel. Hereby I have attached the code, excel sheet and converted pdf also for your reference. I need output like in the attached PDF.

Regards
Prabu R

Dear Fayyaz,

Any update on this.

Regards
Prabu R

Hi Prabu R,


I have observed the desired output shared by you along with source excel file. The source excel file has a long sheet that cannot be accommodated inside a single slide. So, you need to have multiple images from same worksheet that you can add in presentation as Picture frame on multiple slides. In order to achieve this, you need to first set the print area in terms of rows and column range for worksheet and then render that to image. You can then add image as Picture frame inside slide. You need to repeat the process till you get all desired areas of worksheet as image and then adding them to new slides using Aspose.Slides. I hope this will be understandable. You may please use the following piece of code to get the image of desired worksheet area.

Wb.getWorksheets().get(0).getPageSetup().setPrintArea(“A1:H10”);

I also suggest you to please visit this documentation link to serve the purpose in this regard.

Many Thanks,

Dear Fayyaz,

Thank you for your reply. I have already converted the excel sheet into images based on number of pages. Then I have created the number of slides and insert the images. While inserting the images ,the first image only inserting into the picture frame. Could you please refer the attached documents.

Regards
Prabu R

Hi Prabu R,


I have observed the sample code shared and there seems to be an issue when you are rendering sheet image to stream. You need to reset the stream using following statement before copying sheet image to stream and it will work perfectly.

imageStream.reset();

Please share if I may help you further in this regard/

Many Thanks,

Hi Fayyaz,

Thanks for your response and it’s working fine.

Now I am trying to implement the OLE for multiple pages in excel. While doing the same, I am giving the ole size as particular row and column. But the resulted PPTX doesn’t the expected one.
Could you please provide the solution for this. Hereby I have attached code for your reference.


Regards
Prabu R

Hi Prabu R,


I have observed the presentation file shared by you. I guess you are probably pointing to issue of Ole frame getting resized on double clicking when opening the saved presentation in PowerPoint. If this is the issue then I like to share that an issue with ID SLIDESJAVA-35041 has already been created in our issue tracking system to resolve the issue of OLE frame resizing. I will share the feedback with you as soon as the issue will be fixed.

We are sorry for your inconvenience,

Hi Fayyaz,
I am not pointing that frame resize issue. I have already aware of that 35041 ticket.
We are not able to create the expected rows and columns slides as shown in the attached file. This is our issue.

The exact issue is that the single page has cut down horizontally and open in new slide. For example, in the attached file, the presention has only five columns in first slide and remaining two columns are in eighth slide. Could you please see the files.

Regards
Prabu R

Hi Prabu R,

I have worked with the sample code shared by you and have saved the images from excel sheets that are you adding as Ole frame image. The images are identical and Aspose.Slides is simply setting the provided image as Ole frame Image. For your kind reference, I have attached the generated images of excel sheet from your code along with generated presentation. You will find them identical. You need to look in to your code where you are working with worksheet to get desired image. Please share, if I may help you further in this regard.

Many Thanks,

Hi Fayyaz,

Thank you for your response. It’s working fine.

My new issue is resizing issue.

When we are having single page and implementing ole, the resizing issue is not occur. We are using EMF image format.

When we are having multiple pages and implementing ole for multiple pages, we are facing the resize issue. Here we are getting the number of rows and columns using the ChartArea[] and use that rows and columns as ole size.

My assumption is “imageOptions.setOnlyArea(true);” will be the problematic code.

Could you please provide the solution for this issue.

Note:
We have already faced the resize issue, when we have used the Png image format and set the resolution. Then we have forced to change the image format as .emf to fix that issue by the aspose team. Now the issue has solved, but the image quality is very low.

Regards
Prabu R


Hi Prabu R,


I have observed your comments and have not been able to completely understand your description about single page and multiple page Ole frames. Can you please elaborate the issue and also the probable problematic code sample that you have mentioned belongs to Aspose.Cells. I also suggest you to please consult Aspose.Cells forum in this regard for issue related to Aspose.Cells. Also the low quality EMF image that you have mentioned is related to Aspose.Cells and you may consult Aspose.Cells forum for image quality related issues.

Many Thanks,

Hi Prabu R,


I have seen both sample codes shared by you. In XlstoPPTXSinglePage.java file, you are setting the Ole size rows and columns. Where as in XlstoPPTXMultiplePage.java, you are setting the ole size inside for loop based on sheet.getPrintingPageBreaks(imageOptions) options. I suggest you to please save the images of excel sheets from both codes to files to observe the difference. The issue is not lying inside Aspose.Slides domain. As I suggested earlier, if you are able to observe the difference in rendered excel sheet images, then you may please consult Aspose.Cells forum in this regard for better solution and option. This issue may need some investigation and for this reason, I am suggesting you to please consult Aspose.Cells forum in this regard.

Many Thanks,

Hi Fayyaz,

We are using the Aspose.cells only for converting images. After that we are putting that images in the slides using Aspose.slides jar. When we double click the image, the ole window is opening perfectly. When we close that ole frame the ole size has changed. This is the case when we are having multiple pages like that I have shared the document previously.

But when we are using the single page it’s working fine. (The similar kind of issue was there in single page when we were using .png format and setResolution () methods. It will be solved when we changed the image format into .emf )

Could you please execute the code from your side then only you get better idea about the issue.

The similar kind of issue already raised and logged the ticket from Aspose slides. So that I am believing that the issue from your side. Anyway I ll enquire in the Aspose.cells also.

Regards
Prabu R