Error while opening an excel file : file could not be found

Hi All,


I am using the below code to export data from datagrid to excel.



dtgDailyReports.AllowSorting = false;

                        DataSet ds = new DataSet();

                        ds = (DataSet)ViewState["DailyReport"];

                        dtgDailyReports.DataSource = ds;



                        string fileName = string.Empty;          


                              "attachment;filename="+"Reports_" +lblReportDetails.Text+".xls");

                        Response.ContentType = "application/vnd.xls";


                        Response.Charset = "";



                        System.IO.StringWriter stringWrite = new System.IO.StringWriter();                       

                        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

htmlWrite.WriteLine("<table border=\"0\" width=\"100%\"><tr><td align=\"center\" colSpan=\"9\" > " + "<h1> heading </h1>" + "</td></tr> <tr><td align=\"left\">"+

lblReportDate.Text + "</td><td align=\"right\">" + lblRecordNumber.Text + "</td></tr><TR><TD align=\"center\" colSpan=\"9\">"+

                        lblReportDetails.Text +"</TD></TR></table>");








This code is working fine for both office 2003 and 2007 in almost all machines, but in some machines I am getting the error mentioned below.


‘C:\Documents and Settings\v-lekshs\Local stttings\temporary internet files\content.ie5\016rox13\reports_reports.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


Please suggest me on how to resolve this issue.




12/11/2007 10:25:26 AM 91979 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 57

 Try clearing the "Temporary Internet Files" folder on the machines in question and see if that resolves the error...

Website Design Darlington - - Experts, Information, Ideas & Knowledge - An online resource for professional ASP.NET developers

Please remember to click "Mark as Answer" on this post if it helped you

12/11/2007 1:14:38 PM

Remove the line :


And try exporting to excel. The code works.

I also faced the same problem and i tried as above , the problem is slove.

Thank You.

11/18/2008 11:33:17 AM

Similar Artilces:

Got error after open excel file from server..During Export Excel File
this error appears if you have tried to save a workbook on a drive and you do not have Modify and Delete permissions to the location where the file is being saved. It is also possible that another user has a read lock on the file.Excel saves a file using three steps (if the file already exists in the target location):Creates a temporary file with a randomly generated name, such as 4CCA4100.Deletes the original file.Renames the temporary file to the original file name.If Excel cannot delete the original file or cannot rename the temporary file, this error message appears.To temporarily work a...

Error opening Excel file: "Could not decrypt file"
When trying to open an Excel file programmatically, I get the above error. But this only happens on one specific file. It opens correctly when using Excel. The file is definitely not encrypted. On another file, I get this error: 'filename.xls' cannot be accessed. The file may be corrupted, located on a server that is not responding or read-only. After I cancel the operation, the debugger displays: The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write i...

Pls post code to start/open an Excel file and then close the file
Pls post :- (1) Codes to start/open a particular Excel file (eg xyz.XLS in path c:\abc) and(2) Codes to save this XLS and(3) codes to close this XLS file preferably in VB. I want to just keep the Excel file opened and saved at the background (ie without notice to users. Thanks a lot.Thanks in advance for the help. I will try to credit the ones who helped but most important is we really do sincerely thanks to all who have helped. Please help !!!Thanks in advance for the help. I will try to credit the ones who helped but most important is we really do sincerely thanks ...

Trying to get to open file on remote server
The title is kind of lame. What I'm doing is that I had been developing on the production server (don't ask), and now I've moved development to my workstation. I have a bit of code in an aspx the opens a pre-formatted html and puts it into a label. The code is as follows. Dim FILENAME As String = "D:\Inetpub\wwwroot\articles\news.htm" Dim objStreamReader As StreamReader objStreamReader = File.OpenText(FILENAME) articles.Text = objStreamReader.ReadToEnd() objStreamReader.Close() This worked fine and the aspx on the product...

How to get file and open the file on screen?
Hi all, I am writing a tree view page in ( code behind), the tree will create folders and populate file names in the folder. Then I have to create a getfiles.aspx so that user can click on the file name and open the html file on screen in a separate page. In the main tree view page, I have a code to retrieve appropriate file names in the folder: oTree.Add(ChildFolder, "a0_0_0", "Actual vs. Weekly", False)                    Dim sPath As String      &n...

Getting [dcc32 Error] E2161 Error: RLINK32: Error opening file Urgent [Edit]
Getting [dcc32 Error] E2161 Error: RLINK32: Error opening file while doing build/compile. (Note : my files are in shared server , whenever i compile the project i'm getting the above mentioned error at that time i was not able to connect to shared server . but other time i was able to connect to shared server.) please let me know that , what could be the reason for this error and how can i resolve this error. becasue of this error i'm not able to complete my works. please do the needful. Edited by: karthik thirumoorthi on Oct 31, 2014 2:53 AM ...

Error in different perl scipt file
Dear Friends, I am beginner & i am new in perl scripting language, currently i using perl 5.8.8 version. I installed DBI module through CPAN to connect different database. Yes i got output by connecting to the database. My problem is : My first perl script filename is : My second perl script filename is : * When i run my first perl script file ( ) it running and i got the output. * But when i used to run my second perl script file ( ) its not running & i didn't get the output. Its showing "In...

Error meessage when openning file
hey, we are "green" at, and we have an issue when trying to open an project that was created in another computer. please asist ASAP, since we are stucked with no idea for sovling this issue.   Thanks, Moshe and Noa. an project file opened in another computer needs to point to the same URL that when it was created: if it was in, for example, http://localhost/test the new computer will have to have a virtual directory with the name of 'test' and point to where the solution file is.  "Never argue with an idiot; He will drag you down to his level ...

Open file error when backing up compressed files.
Hi I used Server consolidation utility to copy compressed files ( Access Database) from Netware 5.1 SP5 (Traditional netware file system) to Netware 6.5 SP2 (NSS. Arcserve 9.01 fully patched runs on the NW65 server every night and backs itself up daily. I have noticed that during the compare of these compressed files, the Arcserve reports the following error: E3011 Failed to open file ( name of the file), Permission denied I have changed the file sharing access mode within arcserve to "Deny Write", "Deny None", but the problem hasn't gone away. Any sugg...

downloading files, get errors, as file could not be saved.
Name: Egon Mainey Email: Product: Deer Park Summary: downloading files, get errors, as file could not be saved. Comments: I've tried to download a few files from nvidia and, both times I get the following C:/docume~1\admin~1\locals~1\temp\oivoh98f.exe could not be saved, because the source file could not be read. I don't know weather it is a problem with XP64 or deerpark. I've had to resort to IE to get the files, which worked fine. If I've mad a mistake let me know or point me in the direction of the work around, you got m...

Error E1026 File Not Found (dfm files)
I am using Delphi 2009. When I try to compile or build my project, I am getting multiple instances of the following error [DCC Error] E1026 File not found: [myunit].DFM These are units which are not in my project, but are in other projects that I have successfully built and run. All the dcu files are in one directory, and this directory is on the library path for my current project. I can overcome the problem by putting all the source file directories on the library path, but I do not understand why I have the problem. As it happens, I have the source files. But if I only had the d...

Cannot open a database file or file gets corrupted
We're running nsbs 6.5sp3 and client 4.91sp1. Sometimes in our custom made database program, we get an error message that a particular file cannot be opened. Closing and then reopening the program corrects the problem. The program exe and dll files reside in the workstation while the database files are in the server sys drive. Two questions. 1. TID10095627 says to enable level 2 oplocks if a server side database application is in use. If the database files are on the server but the executables are on the workstation, should we enable the oplocks? Currently this opti...

error open excel file
Hi, can anyone help me why the following code doesn't work? ole_1.object.Application.Workbooks.Open (ls_filenm, 0, False, 5, ls_password) fyi, ole_1 is an OLE CONTROL BEN Does it fail or simply not do anything? -- Larry Cermak [Team Sybase] Branick Consulting, Inc. EAServer & PowerBuilder Consulting & Training EAServer and PowerBuilder Computer Based Training Courses "Ben" <> wrote in message news:46f7834e@forums-1-dub... > Hi, > > can anyone help me why the following code doesn'...

Error opening Excel files
Hello all, I'm using some vbScript in my page to open Excel and a spreadsheet that is accessible via a WebDav folder.  This works fine for everyone except for just one of my users.  In her case, it works sometimes, but at other times the following error happens:  -2147417851 -- The server threw an exception. The vbScript code: dim app set app = createobject("Excel.Application") app.Visible = true app.Workbooks.Open(document.getElementById("ctl00_ContentPlaceHolder_FileLabel").innerHTML) app.UserControl = true Any ideas would be a...

Web resources about - Error while opening an excel file : file could not be found -

2010 Winter Olympics opening ceremony - Wikipedia, the free encyclopedia
Canadian fiddlers perform during the Opening Ceremony of the XXI Olympic Winter Games, Feb. 12, 2010, at BC Place stadium in Vancouver. The Opening ...

Facebook Testing Opening Of Links By Android App?
Facebook appears to be using the latest beta version of its Android application to quietly test allowing the app to open links, ...

Into Film Festival opening Q&A
Today I met Malala. She was giving, utterly graceful, compelling and intelligent. That might sound obvious but I was struck by this even more ...

Mandarin Duck Furniture carves out niche market in wake of IKEA opening
One Fyshwick furniture retailer has changed its business practices to offer niche services.

Star Wars' ticket sales surge toward biggest opening weekend of all time
Star Wars: The Force Awakens hurtled toward $125 million in US and Canadian ticket sales and a potential record-breaking $225 million through ...

'Star Wars' Blasts Opening Weekend Record With $238 Million
To say that the force is strong with this one isn't nearly enough.

#StarWars Opening Weekend: 5 Million Tweets, 140 Million Facebook Interactions
... was a huge success on Facebook , as well. The social network announced Monday that more than 64 million people were talking about it on opening ...

The Opening Bell in sports, December 21, 2015 - Business Insider
These are the plays your friends and coworkers will be talking about Monday morning.

Weekend Box Office: Star Wars The Force Awakens A Box Office Opening Weekend Giant
What do you get when you mix one of the world's most popular sci-fi fantasy franchises with the world's most effective corporate marketing machine? ...

Star Wars box office opening weekend: 'Star Wars: The Force Awakens' zooms past record - Dec. 20, 2015 ...
Disney's "Star Wars: The Force Awakens" destroyed box office records this weekend The film flew past the opening weekend record held by Universal's ...

Resources last updated: 12/22/2015 2:33:37 AM