473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Excel trouble

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
3 5599

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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
1
by: Andre Ranieri | last post by:
I'm having trouble programatically inserting an Excel file into an Image column in our CRM package's SQL 2000 database. The function appears to work ok, but when I attempt to access the file through...
3
by: Mansi | last post by:
I'm trying to use excel automation (from visual c# .NET) to fill data in a range by using arrays. I am using Microsoft's Knowledge Base Article 302096 as a reference and using the example listed...
18
by: lgbjr | last post by:
Hi All, I have a VB.NET app that, among other things, writes data to Excel. I am having trouble getting the Excel process to terminate after I quit Excel. I found an article related to this...
12
by: kath | last post by:
How do I read an Excel file in Python? I have found a package to read excel file, which can be used on any platform. http://www.lexicon.net/sjmachin/xlrd.htm I installed and working on the...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
0
by: Marc Scheuner | last post by:
Folks, we're trying to stream back a result set from a SQL query into Excel from our ASP.NET application. Basically, we're doing this here: Response.ContentType = "text/csv";...
1
by: Marc Scheuner | last post by:
Folks, we're trying to stream back a result set from a SQL query into Excel from our ASP.NET application. Basically, we're doing this here: Response.ContentType = "text/csv";...
2
by: gellis72 | last post by:
I'm working on a program that imports a bunch of data from a folder full of Excel files and compiles it into an Access DB. The Excel files have a varying number of rows and columns that need to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.