views:

4854

answers:

4

I have a client of my web based application who heavily uses the data from our system for powerpoint presentations.

We currently allow data to export in more traditional file types...PDF, CSV, HTML, and a few others. Powerpoint doesn't seem to be really automated.

Is there a way, on the ASP.NET server side, to automate the creation and on-demand download of a powerpoint file format for a report from a system?

+3  A: 

In this article, Steve suggests using Aspose's Slide application.

He also explains step by step on how to generate the PowerPoint file.

Here are some code excerpts (in VB):

Opening an existing PowerPoint file:

 Dim fs As  System.IO.FileStream = _

   New System.IO.FileStream("c:\mypath\myfile.ppt", _

   System.IO.FileMode.Open, System.IO.FileAccess.Read)

Dim MyPres As Presentation = New Presentation(fs)

fs.Close()

Looping the slides and outputting their template formats:

Dim slides  As Slides = MyPres.Slides

For i As Integer = 0 To slides.Count - 1

   Response.Write(MyPres.Slides(i).Layout.ToString + "<br>")

Next

In his article, he describes more in detail on how to do it.

Andreas Grech
+2  A: 

Well you have two ways of really doing this, without third party tools. The first would be with Automation of PowerPoint, but that requires that your server have PowerPoint installed. The second is to utilize the new pptx file file format and generate the powerpoint document using XML.

I have found that the best way to get started on the XML side is to simply create a powerpoint that does what you want, then save it and look at the XML. You can also review the microsoft documentation. Overall working with the XML formats is pretty easy.

Lastly, there might be some third party items out there, but be careful that they don't require COM automation.

Mitchel Sellers
+2  A: 

In regards to the previous poster, your statement is incorrect.

You really only have one option for server side ASP.NET automation of this process. Use the open xml links mentioned by Ben in the original answer...

Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Format API (Part 1 of 2) Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Format API (Part 2 of 2)

The reason for this is that server side automation of office is completely unsupported and is bad coding practise, running com automation servers that are designed for interactive usage in a non-interactive environment is a potential recipe for disaster.

so in summary use the open xml api and generate your pptx's.

Anonymous Type