Open an Excel file from a server

1

I have the following problem:

I have a button in which I open an excel file, with Process.Start("ruta"); I put the path of the server \server\etc\etc , and it works in my localhost, but when uploading the web app to the server (through IIS ), it does not bring me anything, it only makes a AutoPostBack , I only know that the solution could be related to Server.MapPath() but I do not have much idea of using it ... Agradesco your help please

    
asked by Abi Sanchez 04.03.2017 в 03:04
source

2 answers

1

I see your problem, you want that when the user, click on a link, the application opens (Excel) in your case, already with the document loaded.

I would recommend reading a bit of Client-Server , so you can understand which processes run on the client side and which ones on the server side.

var Excel = new ActiveXObject("Excel.Application");
    Excel.Visible = true;
    Excel.Workbooks.Open("teste.xlsx");

I explain how it works, this is a JavaScript script, there is a document called teste.xlsx in the same place where the .html .aspx .php, etc ... is running at that moment. what it will do is that the Excel on the client side will open the file and show it. this has its limitations, since some browsers do not execute ActiveX sentences, but in IE it works.

Greetings!

    
answered by 06.03.2017 в 22:20
0

Server.MapPath() , you get the path where your application is currently located, then you need to complete that route, placing inside the parentheses the location of the file you want to obtain, for example: Suppose that within our project, we have a folder called Content and in our Excel file, the instruction would be something like this:

Server.MapPath("~/Content/archivo.xls")

I hope you find it useful.

    
answered by 04.03.2017 в 03:34