|
-
Apr 17th, 2013, 11:35 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] launching excel from asp.net app
i have an app that outputs a gridview to excel spreadsheet and adds a couple of rows for accounting.
i'm trying to launch the spreadsheet after its saved off, using
Code:
excelApp.ActiveWorkbook.SaveAs(filename);
excelApp.ActiveWorkbook.Saved = true;
excelApp.Quit();
var si= new ProcessStartInfo {FileName = filename, UseShellExecute = true}; //hits here and crashes
Process.Start(si);
it hits the marked line and crashes that it cant find the file, its automatically saving it to the documents folder on my local machine, and i cant seem to get it to save elsewhere (i have a data directory in the project i use for the other file types) that i would like to save to if possible, but it seems that if you have office installed it don't like it. i could always copy the file from documents to the datastore, but that's a pain in the backside.
so how do i launch excel application using the file i just saved off to show to the bean crunchers? VB examples will work as well, i can translate
Last edited by DirtyHowi; Apr 17th, 2013 at 11:40 AM.
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 17th, 2013, 08:06 PM
#2
Re: launching excel from asp.net app
You can't launch Excel from ASP.NET because the file will be opened on the SERVER and not your computer. What you can do is process the file and serve it for the client to download it.
-
Apr 17th, 2013, 08:14 PM
#3
Re: launching excel from asp.net app
Caution! Microsoft votes heavily against the usage of the office interops in an asp.net environment. I found out the hard way.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Apr 18th, 2013, 08:08 AM
#4
Thread Starter
Hyperactive Member
Re: launching excel from asp.net app
 Originally Posted by sapator
Caution! Microsoft votes heavily against the usage of the office interops in an asp.net environment. I found out the hard way.
then remove it from the framework this is an internal application only, we are licensed to the hilt all i use it for is creating the file.
i'll look at the download thing unless someone wants to throw the old dog a bone with some code
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 18th, 2013, 09:43 AM
#5
Thread Starter
Hyperactive Member
Re: launching excel from asp.net app
for those interested
Code:
excelApp.ActiveWorkbook.SaveAs(Server.MapPath(filename));
excelApp.ActiveWorkbook.Saved = true;
excelApp.ActiveWorkbook.Close();
excelApp.Quit();
Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;filename=" + fileorig + ".xlsx");
Response.WriteFile(filename+".xlsx");
Response.Flush();
Response.End();
works to open the file from the server after it's saved.
--"Tap Dancing On The Brittle Edge Of Sanity"--
-
Apr 18th, 2013, 06:36 PM
#6
Re: [RESOLVED] launching excel from asp.net app
Whatever.
"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment."
http://support.microsoft.com/kb/257757
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|