asp.net - Generate Powerpoint file on the fly - asp.net

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?

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)

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.

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.

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.

There are also other third-party options similar to Aspose Slides, such as OfficeWriter's PowerPoint Writer.
I'm not exactly sure how Aspose Slides works, but with PowerPoint Writer you have an existing, formatted PowerPoint presentation with data markers in it, the you process it with PowerPoint Writer to replace the data markers with data. Here are some examples.

there is another method ,convert your power point presentation to images or xps(silver light presentation) and then use some sort of json(jquery) to show and download them.
i implement the images and xps silver light presentation in my web application

Related

ASP.NET generated excel file has different format than extension

I have a web application made in old asp.net 2.0. I need to generate excel file with specific formated table (the best way if I can load the template and only put data in code behind). To do this I'm trying to use this library CarlosAg.ExcelXmlWriter:
http://www.carlosag.net/tools/excelxmlwriter/sample
And the final file is generated very well, but when I'm trying to open it in MS Excel warning popup appear with information that file has different format than the extension (xls). And also question if I want to open it if I trust the source of file. When I click yes, the file opened properly. On the other pc with different version of Excel, there's also warning, but different - file is broken and cannot be opened, the same in mobile (no possibility to open). What is interesting - I can open that file properly without any warnings in different office program, ex. WPS Office.
So I make two steps back and try to open just simple file generated by the sample of Carlos library and effect is the same. Is there any chance to "fix" the file in code behind so MS Excel could also open it properly without any warnings?
Dim book As Workbook = New Workbook()
Dim sheet As Worksheet = book.Worksheets.Add("Sample")
Dim row As WorksheetRow = sheet.Table.Rows.Add()
row.Cells.Add("Hello World")
book.Save("D:\Folder\test.xls")
You have to give the file extension xlsx.
The older xls is in fact the legacy (closed) binary format of office files.
However, since office 2007, Microsoft has adopted a open xml format for ALL office documents (well, ok, outlook pst, and MS-Access are exceptions). In fact, if you take any office document (word, power-point, excel) etc., try renaming the xlsx document as a zip file. You find that you can now open the zip archive, and you can see/look at and even modify the xml in that document.
(do try this rename as a zip file for fun and giggles - you see how you actually don't even need any 3rd party tools to open, play with, and mess with the content in the zip archive (so, all office documents are in fact a simple zip archive!!!).
So, newer office file formats are in fact xml markup - and you can modify it!!
Anyway, without a doubt that library you are using thus uses the above feature/fact of office documents now being xml formatted and NOT a propriety Microsoft binary format - you can in fact modify such documents now on ANY computer that is able to open a zip file, and modify text files.
As a result, you are giving the document name a legacy binary file name (xls), but opening a xml formatted file (plain text), and thus Excel is detecting this fact/issue. So, you need to give that document the open office xml format extension (xlsx).

asp.net create xlsx and pdf files

I have an intranet web site based app, where I want to do the following:
When a user presses the button, a server-side xlsx template gets filled in with the relevant data from the back-end table and then the file is saved as both xlsx and pdf format.
The reason to save xlsx is to (maybe) make it easier to save as pdf. The pdf version will then be emailed to the user for review.
I cannot use external libraries, so need to do it all from scratch.
Given that, MSFT does not recommend using office automation libraries, what would be the best approach? Any suggestions would be greatly appreciated.
I understand that this is a broad question, but I am looking for ideas and suggestions. Thanks much in advance.
To generate XLSX from a web application, you do not need an XL library. Just generate a table. But, before that, set the content type of the output to a spreadsheet mime type.
Response.buffer=true
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=report.xls"
The browser will download the file as an XL and most spreadsheet programs will process it as a spreadsheet file without any problem.
However, PDFs cannot be generated without a library.
http://www.gnostice.com/nl_article.asp?id=288&t=Can_I_create_and_edit_PDFs_without_using_a_third_party_PDF_library
I think the best solution is using ReportViewer Local control to create a report that could easily exported as XLS or PDF. You could also use its Render method to do it programmatically.

ASP.NET library to extract plain text from Open XML file formats

Is there a pre-existing library to extract plain text form Open XML file formats (e.g. docx, pptx, and xlsx) files?
I require this to populate a lucene.net index.
I've found this example which extracts text from docx and it seems to work okay. But before building my own solution based on this I was wondering if there's something already available for the other file formats?
Before spending cash, it may be worth looking at the IFilter interface - these were/are designed to do exactly what you want.
http://msdn.microsoft.com/en-us/library/ms691105
http://www.codeproject.com/KB/cs/IFilter.aspx
(Some links at the bottom of the codeprject link).
MS provide IFilters for office file types.
http://www.microsoft.com/downloads/details.aspx?familyid=60c92a37-719c-4077-b5c6-cac34f4227cc&displaylang=en
I know that we use this technology to allow us to index PDFs using Lucene but I did not write the actual code and cannot be of much use I am afraid.
If your Google-fu is strong I am sure you can dig up more examples of using IFilters to do exactly what you want.
watch aspose.com, they have a good library to handle both ppt and pptx.
You can try Toxy, an open source text/data extraction framework for .NET. For now, it supports xls, xlsx, doc, docx. It will support pptx in version 1.5 very soon.
For detail, you can check here

I'm looking for a better solution on importing catalog data into Adobe InDesign

The last time I produced a catalog I used a software called EasyCatalog that worked with Adobe InDesign to merge data from a spreadsheet with graphics. I wouldn’t say it was completely successful. I know of one other catalog building software called Catalog Builder by Computer Pundits. I'm just looking for any suggestions from someone who might have gone through this process on what software I should use.
InDesign can create a really beautiful output from XML. Depending on the catalog content's complexity, you can either have a straightforward mapping of the elements in your catalog to the paragraph and character styles of the IDD file, or you may need to preprocess the XML with XSLT.
For example, if your data source can output the content as XML, but it doesn't map easily to InDesign tables, XSLT can be used to make the XML more "IDD-friendly" before you import it.
IDML is another way to handle XML content; instead of importing the XML content manually or with a script into your catalog template, you generate the IDML directly from your XML. (IDML files are a package of XML files that describe the page/spreads, fonts, swatches, text, images, etc. of the InDesign file.) You're probably going to need XSLT consulting help if this is not a skill you already have.
Take a look at the InDesign documentation for XML for the version you use. IDML is for CS4 or CS5.
Have a look at xCS.press by a company in Belgium. XML markup that is parsed to InDesign. Great for product catalogs.
I wouldn't use Catalog Builder by Computer Pundits again. I've used it in the past (mostly their website builder) and it is completely outdated in my opinion. Their templates are not easily customized and it was pretty slow for me. As for their website builder,(in case you're wondering) it's all tables and very little css IDs or Classes throughout the html.
I haven't used InDesign, but it seems there are lot of scripting features.
Easiest thing that comes to mind is creating an XML Schema with IDML to
get data from Excel into an InDesign document.
XML schema basically is a template for XML documents, and they're called XML Maps in Microsoft Office.
Am not familiar with catalog tools, try superuser.com as well for 3rd party tools & tips.
John. have you come across additional solutions since posting this? I wonder if you have considered CatBase or EM Software solutions.
InDesign works wonderfully with XML and XSLT. You can export the data from Windows Excel only to XML, but only when you create an XML-compatible worksheet. Don't save the file as an XML spreadsheet, that file is useless in InDesign.
What I do is either create a schema file (xsd) for the data that you want to use and import that into Excel on Windows (Mac version doesn't support XML) Once the schema is imported you can create an XML worksheet based on this schema and then copy and paste the data from the non-XML worksheet into the XML sheet. Once the data is in the spreadsheet you can export to an XML file and import it into InDesign.
As mentioned above you can map XML tags to Paragraph and character styles and create dynamic layout directly in InDesign or by using an XSLT to structure the data before you import it.
MS Access allows you to export directly to XML. If you move your data to InDesign you can save the time needed to build the XML spreadsheet. Image references have to be built properly before you export to XML or build an XSLT that will do it on the fly as you import the data in to your layout.
The entire process is described in detail in the book A Designer's Guide to Adobe InDesign and XML.
If the data is in MS Access Woodwing has a product that allows you to interface and import data for a catalog. I have not used it personally but I know people who have. Also, another product called In-Data also interfaces with InDesign, but I have no experience with that either. I usually just use XML and XSLT myself.
I've used EasyCatalog very successfully for a number of years now, even for really large catalogs (35,000+ articles). In the meantime, I offer EC consulting and hands-on user training as well.
I'd need many more details of what went wrong with your specific catalog in order to be able to point your attention to a different solution that may better fit your needs.
I personally would not recommend Jim Maivalds solution because a) Excel and Unicode are not friends b) working with Excel and XML really is a pain c) the process is relatively complicated d) you need a lot of specialized skills regarding XML, XSLT programming and so on e) it's not bi-directional f) when updating you'll do the whole process again.
With EasyCatalog, you just import your data into a panel and place them from there into your document, from manually up to fully automatically. It's really easy, and it's bi-directional - so you can update your document from the database at any time and - if you need to - your database from your document. By the way, you can import your data directly from Excel into an EasyCatalog panel as well.
However, EasyCatalog might not be the best solution if graphics are included in you spreadsheet as well - but who would ever include the real graphics in a spreadsheet instead of the name (and maybe path) to the actual graphic files?

generating nicely formatted excel files in ASP.net without having Excel on server

Generating normal columnar data in excel file is quite easy but does any one of you have generated excel files having datas in different blocks placed in different sheets and beautifully formatted without having to manipulate the excel file using COM [which i want to avoid]. Any ideas would be really helpful.
The output excel file should be compatible with Office 2003 + office 2007
Don't know exactly (as I've Excel installed on both my dev and server machines) but I think ExcelPackage can do the trick.
Check spread sheet gear, with the help of spread sheet gear I have created excel with very good formating as well
http://www.spreadsheetgear.com/
If you're not creating many spreadsheets, or don't wish to buy a product which makes this easier, your solution might be to use templates.
Create a excel document, in the style you want, then save it as xml.
Then modify the xml document as you like, using place holders or whatever, to generate your documents.
This works for simple reports where you don't want to use a 3rd party product.
For anything else I'd recommend a product specializing in this.
You can check SmartXLS for .net.

Resources