Excel 2003 cannot open Output file

F

Fendi Baba

I created an ASP.net page which opens excel. This works fine in Office
2007. However, Excel 2003 runs in an error which states "cannot read
output file".

Hee is the VB code and below is the ASPX code.


Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Web.UI


Partial Class admin_excel
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not IsPostBack Then

Response.Clear()
Response.ContentType = "application/vnd.ms-excel"

Try
con.Open()

Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT
gown_orders.StudentID,gown_studentinfo.FullName,gown_studentinfo.NRIC,gown_studentinfo.Gender
As Sex, gown_orders.GownSize As Size, gown_orders.Rental,
gown_orders.DeliveryOption As Delivery, gown_orders.HomeContact As
Contact, gown_orders.HPContact As Mobile,gown_orders.OrderDate,
gown_orders.IssueDate,gown_orders.Refunded, gown_studentinfo.School,
gown_studentinfo.Program, gown_studentinfo.GraduationSession FROM
gown_orders INNER JOIN gown_studentinfo ON gown_orders.StudentID =
gown_studentinfo.UserID", strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewOrderList.DataSource = ds.Tables(0)
GridViewOrderList.DataBind()
GridViewOrderList.RenderControl(htmlWrite)
Catch ex As Exception

con.Close()
Exit Try

Finally
con.Close()

End Try
End If


End Sub
End Class

============================================


Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Web.UI


Partial Class admin_excel
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not IsPostBack Then

Response.Clear()
Response.ContentType = "application/vnd.ms-excel"


Try
con.Open()

Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT
gown_orders.StudentID,gown_studentinfo.FullName,gown_studentinfo.NRIC,gown_studentinfo.Gender
As Sex, gown_orders.GownSize As Size, gown_orders.Rental,
gown_orders.DeliveryOption As Delivery, gown_orders.HomeContact As
Contact, gown_orders.HPContact As Mobile,gown_orders.OrderDate,
gown_orders.IssueDate,gown_orders.Refunded, gown_studentinfo.School,
gown_studentinfo.Program, gown_studentinfo.GraduationSession FROM
gown_orders INNER JOIN gown_studentinfo ON gown_orders.StudentID =
gown_studentinfo.UserID", strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewOrderList.DataSource = ds.Tables(0)
GridViewOrderList.DataBind()
GridViewOrderList.RenderControl(htmlWrite)





Catch ex As Exception

con.Close()
Exit Try

Finally
con.Close()

End Try
End If


End Sub
End Class


===============================================

Any ideas why Excel 2003 cannot open the file?

Thanks
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top