Click here to Skip to main content
15,916,188 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Limiting decimal places Pin
utservoalius11-Aug-05 16:05
utservoalius11-Aug-05 16:05 
GeneralRe: Limiting decimal places Pin
rwestgraham11-Aug-05 16:20
rwestgraham11-Aug-05 16:20 
GeneralList machines on the network Pin
Duncan Edwards Jones11-Aug-05 3:43
professionalDuncan Edwards Jones11-Aug-05 3:43 
GeneralRe: List machines on the network Pin
Duncan Edwards Jones13-Aug-05 13:20
professionalDuncan Edwards Jones13-Aug-05 13:20 
Generalstored procedures Pin
Anonymous11-Aug-05 3:32
Anonymous11-Aug-05 3:32 
GeneralRe: stored procedures Pin
toxcct11-Aug-05 3:38
toxcct11-Aug-05 3:38 
GeneralRe: stored procedures Pin
alexvw11-Aug-05 5:36
alexvw11-Aug-05 5:36 
QuestionHow to export dynamically generated html table to Excel Sheet Pin
Smitha Bavandla11-Aug-05 3:05
Smitha Bavandla11-Aug-05 3:05 
I have an aspx page("for generating report") in which i have 4 table tags("
" for heading of report etc.) and the rows and cells to them are dynamically created based on the values retrieved from database in the form od dataset which results 4 tables. For ex:
Dim HeaderRow = New HtmlTableRow
Dim HeaderCell = New HtmlTableCell
HeaderCell.Height = "5"
HeaderCell.Attributes.Add("ALIGN", "center")
HeaderCell.Attributes.Add("CLASS", "ins-popupheader")
HeaderCell.InnerText = ds.Tables(0).Rows(0)("Title") & " - Content Report"
HeaderRow.Cells.Add(HeaderCell)
tblHeader.Rows.Add(HeaderRow)

Now the problem is.... I have an anchor tag on my report page "Export as CSV" on click of which I need to export the contents of the page to an Excel sheet.
I tried with the following code:

Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("Content-Disposition", "attachment;filename=Ebom.xls")

Dim dsExport As DataSet = Session("Contentds")
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim dgGrid As New DataGrid

Dim i As Integer = 0
For Each table As DataTable In dsExport.Tables
dgGrid.DataSource = dsExport.Tables(i)
dgGrid.DataBind()
dgGrid.RenderControl(hw)
i = i + 1
Next

' Write the HTML back to the browser.
Response.Write(tw.ToString())

' End the response.
Response.End()

It generates an Excel sheet but the format is not clear and I am missing some contents of my report page. I request if any one can help me in directly exporting the contents of my report page to Excel.
A quick response is appreciated........
Thanking in anticipation
--smitha



Smitha Bavandla
GeneralEditable ListView Pin
Greeky10-Aug-05 22:40
Greeky10-Aug-05 22:40 
GeneralDataGridColumn Problem Pin
Greeky10-Aug-05 22:19
Greeky10-Aug-05 22:19 
Generalspecial Excel Datagrid Pin
Greeky10-Aug-05 22:18
Greeky10-Aug-05 22:18 
GeneralAdding Nodes to TreeView from FIles Pin
AyBee10-Aug-05 20:21
AyBee10-Aug-05 20:21 
GeneralRe: Adding Nodes to TreeView from FIles Pin
Christian Graus14-Aug-05 14:25
protectorChristian Graus14-Aug-05 14:25 
GeneralRe: Adding Nodes to TreeView from FIles Pin
AyBee15-Aug-05 18:45
AyBee15-Aug-05 18:45 
QuestionHow do I pass an Array/ArrayList to a WebService ... Pin
MaWeRic10-Aug-05 19:45
MaWeRic10-Aug-05 19:45 
AnswerRe: How do I pass an Array/ArrayList to a WebService ... Pin
Christian Graus10-Aug-05 20:46
protectorChristian Graus10-Aug-05 20:46 
GeneralRe: How do I pass an Array/ArrayList to a WebService ... Pin
MaWeRic10-Aug-05 21:44
MaWeRic10-Aug-05 21:44 
GeneralRe: How do I pass an Array/ArrayList to a WebService ... Pin
Christian Graus11-Aug-05 12:43
protectorChristian Graus11-Aug-05 12:43 
GeneralRe: How do I pass an Array/ArrayList to a WebService ... Pin
MaWeRic11-Aug-05 19:34
MaWeRic11-Aug-05 19:34 
GeneralRe: How do I pass an Array/ArrayList to a WebService ... Pin
Christian Graus14-Aug-05 13:23
protectorChristian Graus14-Aug-05 13:23 
GeneralRe: How do I pass an Array/ArrayList to a WebService ... Pin
MaWeRic14-Aug-05 14:02
MaWeRic14-Aug-05 14:02 
GeneralRe: How do I pass an Array/ArrayList to a WebService ... Pin
Christian Graus14-Aug-05 14:24
protectorChristian Graus14-Aug-05 14:24 
GeneralTab Pages Pin
Anonymous10-Aug-05 19:42
Anonymous10-Aug-05 19:42 
GeneralRe: Tab Pages Pin
MaWeRic10-Aug-05 19:47
MaWeRic10-Aug-05 19:47 
GeneralRe: Tab Pages Pin
Anonymous10-Aug-05 19:58
Anonymous10-Aug-05 19:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.