By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,453 Members | 1,562 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,453 IT Pros & Developers. It's quick & easy.

Excel trouble

P: n/a
Hello,

I want to open an Excel spreadsheet in my ASP.NET/C# page, but the file cannot be found. Here's the code:

<code><snip>
using Excel;
using System.Reflection;
using System.Runtime.InteropServices;
<snip>
private Excel.Application excelApp = new Excel.ApplicationClass();
private void Page_Load(object sender, System.EventArgs e)
{
Excel.Workbook newWorkbook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);
excelApp.Visible=true;

string workbookPath = "c:/BACKUP/test.xls";
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,0, false, 5,
"", "", false, Excel.XlPlatform.xlWindows, "",true, false, 0, true);

}

When I run that code I get the following error:
System.Runtime.InteropServices.COMException: 'test.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct. If you are trying to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.

Any ideas, suggstions or recommendations graciously accepted,

gogoray

Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

string workbookPath = "c:\\BACKUP\\test.xls";

???
"gogoray" <an*******@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
Hello,

I want to open an Excel spreadsheet in my ASP.NET/C# page, but the file
cannot be found. Here's the code:

<code><snip>
using Excel;
using System.Reflection;
using System.Runtime.InteropServices;
<snip>
private Excel.Application excelApp = new Excel.ApplicationClass();
private void Page_Load(object sender, System.EventArgs e)
{
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);
excelApp.Visible=true;

string workbookPath = "c:/BACKUP/test.xls";
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,0,
false, 5,
"", "", false, Excel.XlPlatform.xlWindows, "",true, false, 0, true);

}

When I run that code I get the following error:
System.Runtime.InteropServices.COMException: 'test.xls' could not be found.
Check the spelling of the file name, and verify that the file location is
correct. If you are trying to open the file from your list of most recently
used files on the File menu, make sure that the file has not been renamed,
moved, or deleted.

Any ideas, suggstions or recommendations graciously accepted,

gogoray
Nov 15 '05 #2

P: n/a
oh, yeah. the "\\" double slash was a last desperate attempt to get this to work.

it also fails with

string workbookPath = "c:\BACKUP\test.xls"

----- Daniel Bass wrote: ----
string workbookPath = "c:\\BACKUP\\test.xls"

??
"gogoray" <an*******@discussions.microsoft.com> wrote in messag
news:AA**********************************@microsof t.com..
Hello

I want to open an Excel spreadsheet in my ASP.NET/C# page, but the fil
cannot be found. Here's the code

<code><snip
using Excel
using System.Reflection
using System.Runtime.InteropServices
<snip
private Excel.Application excelApp = new Excel.ApplicationClass()
private void Page_Load(object sender, System.EventArgs e

Excel.Workbook newWorkbook
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et)
excelApp.Visible=true

string workbookPath = "c:/BACKUP/test.xls"
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,0
false, 5
"", "", false, Excel.XlPlatform.xlWindows, "",true, false, 0, true)

When I run that code I get the following error
System.Runtime.InteropServices.COMException: 'test.xls' could not be found
Check the spelling of the file name, and verify that the file location i
correct. If you are trying to open the file from your list of most recentl
used files on the File menu, make sure that the file has not been renamed
moved, or deleted

Any ideas, suggstions or recommendations graciously accepted

gogora

Nov 15 '05 #3

P: n/a
"c:\BACKUP\test.xls";

will always be wrong unless there are "\\" or the string is prefixed with @.
"gogoray" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
oh, yeah. the "\\" double slash was a last desperate attempt to get this to
work.

it also fails with:

string workbookPath = "c:\BACKUP\test.xls";
----- Daniel Bass wrote: -----
string workbookPath = "c:\\BACKUP\\test.xls";

???
"gogoray" <an*******@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
Hello,

I want to open an Excel spreadsheet in my ASP.NET/C# page, but the file
cannot be found. Here's the code:

<code><snip>
using Excel;
using System.Reflection;
using System.Runtime.InteropServices;
<snip>
private Excel.Application excelApp = new Excel.ApplicationClass();
private void Page_Load(object sender, System.EventArgs e)
{
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);
excelApp.Visible=true;

string workbookPath = "c:/BACKUP/test.xls";
Excel.Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath,0,
false, 5,
"", "", false, Excel.XlPlatform.xlWindows, "",true, false, 0, true);

}

When I run that code I get the following error:
System.Runtime.InteropServices.COMException: 'test.xls' could not be
found.
Check the spelling of the file name, and verify that the file location
is
correct. If you are trying to open the file from your list of most
recently
used files on the File menu, make sure that the file has not been
renamed,
moved, or deleted.

Any ideas, suggstions or recommendations graciously accepted,

gogoray


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.