Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net - Generate Powerpoint file on the fly

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?

like image 329
pearcewg Avatar asked Dec 19 '08 16:12

pearcewg


3 Answers

There's some documentation on MSDN about the OpenXML format that they're using:

  • 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)
like image 165
Zhaph - Ben Duguid Avatar answered Oct 02 '22 16:10

Zhaph - Ben Duguid


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.

like image 26
Andreas Grech Avatar answered Oct 02 '22 16:10

Andreas Grech


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.

like image 32
Mitchel Sellers Avatar answered Oct 02 '22 16:10

Mitchel Sellers