LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.dotnet.framework.aspnet,microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Datagrid to Excel problem (ASP dot net)

I use the following code:

Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged
Dim sFile As String = Session("User") & "-Customer List-" & Today()
sFile = sFile.Replace("/", "")
RbtnExport.Visible = False
Select Case RbtnExport.SelectedItem.Value
Case "Excel"
Response.ContentType = "application/x-msexcel"
Case "Word"
Response.ContentType = "application/msword"
End Select
Response.AddHeader("Content-Disposition", "Attachment; filename=" & sFile)
End Sub

To allow a user to save a web page with a datagrid on it into an Excel
sheet.

They'll run a page using a Web check box, which renders it to an ASPX page,
and then when they have the final product on the screen, they click the
radio button for Excel, and it prompts them to Open or to Save the file.

The problem occurs when you save or open the file.

The datagrid has 9 columns in it, a product code, description, unit of
measure, price, product hierarchy number, weight and UPC code, etc.

The data grid has a header & a footer on it, and each column in the datagrid
is sortable.

If I have a short list, one of maybe less than 20 records, I can click the
Excel button, it prompts me to save it, and it'll save as a document with a
..xls extension. You can then open it up without incident.

If the list is longer - say maybe over 40-50 rows in length (up to the
longest list, with up to 500 or more items in it), it will save it with a
..xls extension, but you cannot open it.

Excel attempts to open it, but it immediately gives you an OK box that says
"Unable to read file". It works fine if the number of rows is small (under
25 or so), but not if it's much more than that. Thus far, I have not seen a
pattern in it. The file that will open is 20K in size, the one that will
not is 400K in size. I have figured that the difference is between 30 and 50
records before it gives me this problem. I've noticed that each line
appears to add about 1K in file size to it the excel file.

It doesn't appear to be a memory issue, as excel works fine any other time,
and will open spreadsheets much larger than this. I've confirmed that it's
not version specific in Excel, as it barfs on every version of excel it
tries to open it in.

Any idea as to what is going on here on this problem? Is there any way I
can step thru the open of the file in Excel, to see the specific problem
Excel has with opening the file?

Any help/advice appreciated.

Thanks,

SC


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Weird problem with Excel 2000...Worksheets disappearing in a shared Excel file BrianL_SF Excel Discussion (Misc queries) 2 October 10th 06 08:27 PM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
DataList or DataGrid link to Recordset or External Data No Name Excel Programming 0 November 11th 03 02:58 PM
Datagrid ActiveX Control MK[_2_] Excel Programming 3 August 8th 03 09:30 AM


All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"