简体   繁体   中英

Excel Interop saving file on host server instead of local machine

The Project is an ASP.NET application used to fetched Survey Evaluation from Database and export in excel.

I am using excel interop for generating the report in excel. I later came to know that Microsoft don't support the server side automation using interop library but I initially choose it as closed/openxml don't support the excel graph and chart.

I deployed my application on the server and everything is running fine as excepted, except that the generated file is getting saved on the server instead of the local machine from where the application is called.

string foldername = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";

Xlworkbook.SaveAs(""+foldername+"\\Evaluation.xlsx",51, missing, missing, missing,missing, Excel.XlSaveAsAccessMode.noxlchange,missing, missing, missing, missing, missing);

Saving the file in C:\\User\\Asp.Net v4.0\\Downloads\\ --- on the server instead of C:\\User\\Username\\Downloads\\ --- on the local machine

NOTE: Asp.Net v4.0 is the name of the IIS pool on the which the application is deployed.

The code runs on the server, not on the client, hence the file being saved on the server.

Use a library that does support creating graphs in Excel file format without using excel to solve the interop problem (you really don't want that on a server, apart from licensing).

Then just let the user download the file from the web application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM