Create Excel Worksheet, do i need Excel installed on the server?

I have actually produced an application that uses Microsoft.Office.Interop.Excel, in my regional and testing environments whatever worked great, however the app does not work in the production environment.

Turns out I have Office installed in your area, as does the Test server, nevertheless, the production server does not have Excel installed.

I actually can’t return and change my code, nevertheless, I would truly not like to have to install Excel on the production server.

Do I have any other choices other than setting up Office Excel on the production server to obtain the application working?

Office Interop does need that Office be set up on the server.

In the more general case, you do not need Excel to develop worksheets, and you need to avoid any option that requires it for web use. That consists of office interop: it does not scale in a web environment.

Did you look for some totally free expense excel parts for.NET. These two components have totally free variation for developing excel files:

iditect excel component (xlsx and xls files as much as 150 rows).
excel jetcell net part (without restriction composes text to excel files xls and xlsx).

The Excel interop libraries work by opening the Excel application in the background to process the spreadsheet. So without updating your code, you will need to have actually Excel set up on the server. Using interop is an extremely sluggish and error susceptible solution to working with Excel from ASP.NET, the link Joel gave offers several great options.

i have handled to produce a stand out file with interop, and now i desire that stand out file to be downloaded in web internet browser instead of conserving in drive.

this is what i have tried so far to produce stand out file. require some englightment. “this code conserve stand out file to drive, which is not the result that i want to attain.”.

I utilized to produce stand out and returned a FileStereamResult on my controller action. I believe you can not do that with the Excel library you are using.

public FileStreamResult MyAction(parameters)
var workBook = CreateWorkbook(parameters);
var stream = new MemoryStream();
stream.Position = 0;
return File(stream, "attachment;filename=myfile.xls", "myfile.xls");

You will require to conserve the file on the server temporarily in order to serve it to the client.

You can save it in a temperature course utilizing utilities in System.IO.Path like GetTempPath() to put the file in a location the OS will clean up the file up immediately when it’s not required.
var filePath = System.IO.Path.GetTempFileName();
//then save the file to the filePath
return File(filePath);

I have no idea exactly what web server you’re utilizing but if you’re utilizing MVC you ‘d do something like this to serve the file in your controller.

Leave a Reply

Your email address will not be published. Required fields are marked *