473,320 Members | 1,977 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,320 software developers and data experts.

Excel 2003 cannot open Output file

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("LocalSq lServer").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,go wn_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("LocalSq lServer").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,go wn_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

May 18 '07 #1
0 1825

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andre | last post by:
I'm not sure if this is the best place for this post or not, but I can't find many asp newsgroups anymore. I have an app that's 3-4 years old, and has been working just fine. One of the pages...
8
by: DC Gringo | last post by:
I have a simple button that should open another window and export a datagrid to an Excel file. I'm getting: "Name 'window' is not declared." What do I need to declare or import? <INPUT...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
0
by: Ned Balzer | last post by:
I have a puzzling problem. I am using some code I found in another thread here to output the results of a gridview to excel. Here is the subroutine: Sub SendToExcel(ByVal Source As Object,...
5
by: =?Utf-8?B?U3R1YXJ0?= | last post by:
Hi There I have been having a play around with the following code to display a datagrid in Excel (all from Steve Orr's site): Private Sub btnTechServAccred_Click(ByVal sender As System.Object,...
3
by: rlntemp-gng | last post by:
RE: Access 2003/Excel 2003 Problem: After I close the Access application completely, I go out to the Task Manager and there is an Excel.exe object still sitting out there. My Access...
8
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. The data opens up correctly in MS office Excel 2007 but when we use a mahcine with MS Office 2003 we encountered a message, "Cannot read output file" Is...
4
by: =?Utf-8?B?THluZXJz?= | last post by:
Hello All, We have a VB.NET application writen using VS 2003. This application apens an excel file from a vendor, reads the data and performs whatever functions it needs. We recently upgraded our...
0
by: =?Utf-8?B?ZGlzcGxheW5hbWU=?= | last post by:
The following code used to outputs to Excel 2003 fine. Do I need to change it to output to Excel 2007? <% Response.ContentType = "application/vnd.ms-excel" Response.AddHeader...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.