all groups > dotnet interop > july 2003 >
You're in the

dotnet interop

group:

Opening Excel workbook from ASP.NET Page


Opening Excel workbook from ASP.NET Page Michael
7/31/2003 3:05:10 AM
dotnet interop:
I have an Excel Object control on my ASP.NET page. How can
force a specific Excel workbook ( say "c:\myfile.xls") in
this object when my page opens. Alternatively, how can I
Opening Excel workbook from ASP.NET Page Hanre Garbers
8/1/2003 12:04:46 AM
Hi

As I understand this your Excel object control expects a
path like 'c:\files\file1.xls' and not
like 'http://mysite/files/file1.xls' also not relative
like 'files/file1.xls'. If this is the case you can use
the Server.MapPath function. It takes the relative path
of the document as input and return the hard drive
location.

E.g. Server.MapPath("files/file1.xls") would return
something like 'c:\files\file1.xls', which your object
control could then use.

Place it in your Page_Load event e.g.:
me.xlsControl.load(Server.MapPath("files/file1.xls"))

or

me.xlsControl.Document = Server.MapPath("files/file1.xls")

Hope this helps!

Ta
[quoted text, click to view]
AddThis Social Bookmark Button