Excel trouble

G

Guest

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.xlWBATWorksheet);
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
 
D

Daniel Bass

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

???


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.xlWBATWorksheet);
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
 
G

Guest

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"

??


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.xlWBATWorksheet)
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
 
D

Daniel Bass

"c:\BACKUP\test.xls";

will always be wrong unless there are "\\" or the string is prefixed with @.


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";

???


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.xlWBATWorksheet);
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top