creating excel, powerpoint and documents in asp.net and saving the files - c#

I have a dropdownlist in my application with items document, excel and powerpoint. When i click on each of them say for example excel, an excel sheet should open and I write in it and I should be able to save the file in gridview. How can I do that?

Take a look at the NPOI project. From the website:
[N]POI is an open source project which can help you read/write xls,
doc, ppt files. It has a wide application. For example, you can use it
to generate a Excel report without Microsoft Office suite installed on
your server and more efficient than call Microsoft Excel ActiveX at
background; you can also use it to extract text from Office documents
to help you implement full-text indexing feature (most of time this
feature is used to create search engines).
Once you've written a file, you can present it for download in your GridView. Is that what you're after?

Related

How to preview or display or edit an Excel file on web page by C# and .NET framework

Working on a task that displaying or previewing an excel file, which generated by EPPlus, on web page (.aspx).
Now, my problem is all the source point to the keywords: excel web app, excel web service, sharepoint or Excel online, but when i dug into those keywords i lose myself. Most of the information are about how to do the task inside the excel, such as save as html, publish to sharepoint etc. And the rest of the information are delivered by brain-unfriendly example or language.
So I am wondering can someone give me a walk-through method about publishing or displaying or previewing or editing an Excel file on web page(.aspx) by C# language and .NET framework.
Thanks.
You can't natively modify Excel files in web browsers. Browsers can support some files such as Java Applets or Adobe Flash, but those requires plugins, and they don't exist for Excel files.
Instead, you should create an HTML representation of the Excel file, and allow the user to then manipulate the HTML representation. When they're done, generate an Excel file based on their changes.
Alternatively, allow the user to download the Excel file and make their changes, and allow them to publish the changes back to the server by uploading the file.

How can I unzip Office Open XML file in C# and modify its data and re-zip again?

From a console application written in C#, how can I :
extract an Office Open XML file,
Obtain the data part of it modify
the data and re-zip it again
My motivation is to save an excel file with the formats and use it to populate cells via a console application.
Is this possible to achieve, do I need a specific library to that provides Excel files manipulation (unzipping it, modifying it etc.)
For the zip-unzip part i think you can find easily many examples here.
To edit the excel file, I'd suggest you to have a look at Open XML SDK. With it, you can easily edit office files programmatically.
Hope it helps

Word document export from web app

I need to export word documents from a web app. I currently use NPOI for excel export, but it doesn't seem to cover word export.
I've found Aspose Word, is there other valid alternatives?
I need to be able to use a word template document, and bookmarks should preferably be supported.
If you don't mind writing some lines of code you can use OpenXML SDK. It allow you to create from scratch word, excel and powerpoint files. I used it in a project in wich the users uploaded docuemnt templates and then the app replace the bookmark with values taken from DB. The same thing with excel, but workin with cell coordinates
for exporting word documents from a web app, Spire.Doc may useful for you, doc and docx supported.

is there any way to programatically download data list from sharepoint into excel

we have some data (list) stored in sharepoint. i can manually click "Actions"-> "Export to Spreadsheet" and then run a bunch of code on the Excel output.
I now want to do this on a daily basis from a C# application. Is there anyway to programatically automated that download steps that i am doing now. (the site DOES require authentication)
the "Export to Spreadsheet" fires off some javascript (so doesn't directly just point to a URL so i can read in a URL directly (i dont think)
I would recommend getting the data using SharePoint web services and then using NPOI to convert the data into an excel spreadsheet; Use web services so that you are not limited to running the app on the server and NPOI for reading/writing to excel.
if you are not limited to excel and can use other office products, MS-Access 2007 has a very good integration with sharepoint. you can write your macro and vb scripts to run on that with minor adjustments.
you can also use it as a transfer application, if you build a simple EXPORT TO EXCEL macro, and then set it to run periodically.
Basic approach:
One you have created the spreadsheet with "Export to Spreadsheet" in SharePoint, the excel file holds a list which is linked to the sharepoint list.
This is a list object in Excel which allows for refresh from the same SharePoint list at a later date, make changes in excel and update the SharePoint list from these. So updating your download is really a refresh of the list which you originate in Excel

Exporting dataset to Excel file with multiple sheets in ASP.NET

In C# ASP.NET 3.5 web application, I need to export multiple datatables (or a dataset) to an Excel 2007 file with multiple sheets, and then provide the user with 'Open/Save' dialog box, WITHOUT saving the Excel file on the web server.
I have used Excel Interop before. I have been reading that it's not efficient and is not the best approach to achieve this and there are more ways to do it, 2 of them being: 1) Converting data in datatables to an XML string that Excel understands 2) Using OPEN XML SDK 2.0.
It looks like OPEN XML SDK 2.0 is better, please let me know. Are there any other ways to do it? I don't want to use any third-party tools.
If I use OPEN XML SDK, it creates an excel file, right? I don't want to save it on the (Windows 2003) server hard drive (I don't want to use Server.MapPath, these Excel files are dynamically created, and they are not required on the server, once client gets them). I directly want to prompt the user to open/save it. I know how to do it when the 'XML string' approach is used.
Please help.
Thank you.
Is Excel 2007 support absolutely required?
We have used NPOI with great success, and it supports all the features we want (multiple worksheets, formatting, formulas). It is also pretty stable.
The files it produces are in Excel 2003 format though, so they are binary, not OOXML.
This question has been asked before, see here for a better discussion.
You can easily stream the xml response to the user as an XML Excel file.
Any Page:
Open excel Report
Report.aspx:
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition"
, "attachment;filename=" & _fileName & ".xml");
Response.Write("<?xml version=""1.0""?>");
Response.Write(excelXML);
I too had come across similar requirement to export dataset into excel. I used this open source library. It's based on Open XML standards and doesn't use Office Interop. It met my requirement. But, my requirement was basic. So, check if it fulfills your requirement.

Categories