how to display excel sheet in asp.net - c#

I have an excel stored in project folder.
i want to show whole excel,when user click on button showexcel.
once excel open, the user should have write,edit and save options also.

How about the new Excel Web App? You'll have to dig deeper about how to host this. You can test-drive for free with Windows Live Skydrive. Its a fantastic product.
general page:
http://office.microsoft.com/en-us/web-apps/office-web-apps-FX101825822.aspx
how to host:
http://technet.microsoft.com/en-us/office/ee815687.aspx

Related

Refresh data in excel after changing data in sql server in web application

I have a web application that gets data from an sql server then exports the result to Excel.
I would like changes in the database to be reflected in the Excel file without having to re-download the file.
It seems unlikely that you can connect in this way through the web application. You can link Excel documents directly to a database though. Would that help?
For Example
https://support.office.com/en-gb/article/Connect-a-SQL-Server-database-to-your-workbook-22c39d8d-5b60-4d7e-9d4b-ce6680d43bad
You can write excel document with C# code-behind with VSTO (with Excel Document Project Template) and provide programmatic syncing DB. It is very good extensibility point - you can do almost everything: manage content, create extra menus, toolbars, ribbons etc
Alternatively you can connect Excel with DB directly and refresh data by demand.

Need to open the file in client's machine

The question is related to asp.net web site application.
Requirement 1: Need to open an excel file in clients' machine and allow the user/client to modify the
opened excel file.
// After downloading file from ftp location to below path 'excelPath'
String excelPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyApp", "Excel1.xlsx");
System.Diagnostics.Process.Start(excelPath);
Output: Above code working fine with visual studio, but not working after hosting it. Also it seems the file will open in server machine but my requirement is to open it in client machine.
Note: for hosting I am using Microsoft Server 2008 R2.
You cannot access client machine's file system, but user may upload his excel file to your application. Save uploaded file in storage. Let user edit uploaded file and then download it.
Don't use Process.Start as it will not work on client machine
Rather provide a link to the excel file and when the user will click on it, s/he will be prompted to open
I used a Desktop application to fix this. Implemented a flag to check whether the user is logged in, if user is logged in downloaded the excel file and opened it, and pushing data to server periodically till the user is logged in.
This solved my requirements.
Thanks all for there helpful comments.

Creating a stub for editing office documents

I'm looking to create a synchronization mechanism for a document storage service.
The essential idea is that the user downloads a stub file say somefile.stub that contains a link to the file on the server.
When the stub file is clicked on an app on the users machine (associated with .stub) opens up looks in the file and downloads the document from the server in the background.
Once I've got the file locally I'd like to get windows to open up the file in the appropriate editor e.g. word. I really don't want to have to save out the file and then open word or whatever via Process and a command line.
Also, I'd like to be able to grab the document when its saved and send it back to the server to keep everything in synch.
I'd prefer to write the client application in c# if possible.
You have to create a service running continuosly on the client machine, that should orchestrate the stub file transfer and the opening of them. Opening with the proper program can be achieved by using Process with StartInfo.UseShellExecute = true;. You can also use a FileSystemWhatcher to be notified when the external app modify the file.
Here is one solution:
Create a Class 2 WebDAV Server and publish your MS Office documents via it.
In case you target MS Office 2013 you can use the following link to open documents for editing directly from your WebDAV server:
ms-word:ofe|u|http://mywebdavserver.com/path/document.docx
This will eliminate download/upload steps and will work in the SharePoint-like manner. You also do not need to deploy any client application in this case.

how can i open a excel inside a web browser?

I need to open a excel in web browser when click a button.how to do that in asp.net
You can't control and launch software on the client (browser) computer - why? Security.
If this was possible, hackers would have taken over all computers long ago...
Can you please explain exactly what you are trying to do? Instead of asking how to open excel from the browser, if you explain what you need to accomplish, perhaps we can come up with a better idea.
I use Google Docs Viewer for opening a wide variety of files in the browser.
Example:
http://docs.google.com/viewer?url=http%3A%2F%2Fyoursite.com%2Fyourexcelsheet.xlsx
you just need to give the url of the excel in the server
Excel
Only you can open a excel in server you can do.not in Client
You can open and control and excel file on the server side with .net, then you can write an html/javascript frontend (or silverlight) for the actions. But you cannot open the ms excel itself as a dom object etc.
Look into the excel object model for .net.

Does Open Office need to be installed to be used by a deployed application?

I am thinking of using Open Office from my winforms application to produce printouts of data. I would like to reference the API and programmatically manipulate documents from my client PCs. To clarify, I don't want to host a window with Write inside it so users can edit documents from within my application. I just want to programmatically stick a load of data into a document and call print on it, so the only thing a user will see is the print options dialogue box.
I can't install Open Office on my client PCs. Is it possible to xcopy install the Open office dlls (hopefully just a subset) along with my application binaries?
Try AODL
It is a part of the ODF Toolkit.
/Erling Damsgaard
DNS-IT ApS

Categories

Resources