asp.net create xlsx and pdf files - asp.net

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.

Related

download data in excel from database without GridView

I Have to fetch data from database and download in Excel format without DataBind() on any Control.
Is There any Possible way to accomplish this task?
If you need to download in xlsx format, I can recommend ClosedXml - none of the nightmare of interop and requiring Excel on the same machine. Quite easy too - see this example: Adding DatatTable to Worksheet (ADO.net).
See also this example for delivering an Excel file with ASP.net

How to fill an excel template using ASP.NET, VB or C#?

I have a an excel file that has been manually populated, and now needs to be automatically populated using ASP.NET, vb or c#. I've been looking around, and have found examples on how to export a gridview, and data to excel sheet, but not anyway to maintain the format of the original template. I've recently populated a word document using merge fields... does excel have anything similar? Could I break the file down into XML and use that as a template? Any ideas?
Thanks.
Office Writer from soft aritsans will do exactly this. Plus a lot more it is extremely powerful and I have used it to great effect in the past.
The down side is that it is rather expensive!

To read pdf in asp.net

I want to read pdf file and i want to store it's detail in my database.
But i could not read pdf file & store it in sql database in asp.net using c#. So, please give me a solution if anyone knows...
Very very thanx in advance
If you need to effectively parse the contents of the PDF file, you may want to use a PDF management library such as iTextSharp. Otherwise, you could just store the raw file contents using a binary field in your table.
Please see these article, May be these will help you.
http://www.codeproject.com/KB/string/pdf2text.aspx
http://www.codeproject.com/showcase/TallComponents.asp
Else if you can purchase adobe toolkit for this then it will very easy for you to play with PDF.

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.

Making a pdf file easily in asp.net with formatting options for datagrids

I'm looking for an easy way of printing output to a pdf file for users, especially data grids. Formatting options would be a plus.
Potential scenario -> Users view page with 2 data grids -> Users click print -> Page opens a pdf file that they can save/print
Our budget is tight, so a free solution would be ideal, but I'd like to look into and evaluate any other solutions as well.
Thanks for the help!
For a solution using open source iTextSharp, check this article out:
Creating PDF documents in ASP.NET
The question was also discussed here on SO:
How to make pdf ?
Crystal Reports in a PDF file? (check out the link in JP's response)

Resources