Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Error outputting DataGrid to Excel File
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
asteffes




PostPosted: Fri Jul 07, 2006 7:45 am   Post subject: Error outputting DataGrid to Excel File

I am using the code located below to output my datagrid to an excel file.

Everything worked great yesterday, but today there is a problem when you select 'Open' from the "Open, Save, or Cancel" dialogue for the XLS file.

The error looks something like:
"C:\....Temporary Internet Files\....\TimeReport[7].xls' Could not be found. Check spelling and verify location is correct"

I'm guessing that internet explorer is trying to populate an excel sheet that existed yesterday but does not exist today. I've cleared my cookies but it still attempts to fill up these strange excel files.

When I choose the "save" option, it works fine.

Any tips on how to point the code in the right direction when I am opening the excel sheet in a temporary directory?

thanks!

code:

 

Response.Clear()
        Response.AddHeader("content-disposition", "attachment;filename=TimeReport.xls")
        Response.Charset = ""
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.ContentType = "application/vnd.xls"
        Dim stringWrite = New System.IO.StringWriter
        Dim htmlWrite = New HtmlTextWriter(stringWrite)

        dataGrid.RenderControl(htmlWrite)
        Response.Write(stringWrite.ToString())
        Response.End()

Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: