Click here to Skip to main content
15,893,266 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalplay flash movie (.swf) in pocket pc Pin
vb .net beginner15-Feb-05 15:04
sussvb .net beginner15-Feb-05 15:04 
GeneralRe: play flash movie (.swf) in pocket pc Pin
Dave Kreskowiak16-Feb-05 1:55
mveDave Kreskowiak16-Feb-05 1:55 
GeneralRe: play flash movie (.swf) in pocket pc Pin
nicegirl20-Feb-05 21:42
nicegirl20-Feb-05 21:42 
GeneralRe: play flash movie (.swf) in pocket pc Pin
Dave Kreskowiak21-Feb-05 8:05
mveDave Kreskowiak21-Feb-05 8:05 
GeneralRe: play flash movie (.swf) in pocket pc Pin
nicegirl21-Feb-05 22:12
nicegirl21-Feb-05 22:12 
Generalneed help on image processing in vb.net Pin
Tolga Palaoglu15-Feb-05 10:46
Tolga Palaoglu15-Feb-05 10:46 
GeneralRe: need help on image processing in vb.net Pin
Christian Graus15-Feb-05 14:54
protectorChristian Graus15-Feb-05 14:54 
GeneralExport DataGrid to Excel (VB.NET) Pin
hkamdar15-Feb-05 9:52
hkamdar15-Feb-05 9:52 
Hi all,

I want datagrid to be exported to excel (thru button). Following is my code but it is just displaying the header row. P.S.- I'm displaying some data on item databound.

Private Sub btnExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExcel.Click
RenderGridToExcelFormat(dgActivitySummary, "test")
End Sub

'''------------------------------------

Private Sub RenderGridToExcelFormat(ByVal grid As DataGrid, ByVal saveAsFile As String)
' check Excel rows limit
If grid.Items.Count.ToString + 1 < 65536 Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" & saveAsFile & ".xls")
' Remove the charset from the Content-Type header.
HttpContext.Current.Response.Charset = ""
'HttpContext.Current.Response.WriteFile("style.txt")
' Turn off the view state.
grid.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
grid.HeaderStyle.ForeColor = Color.Black
grid.HeaderStyle.BackColor = Color.Red
grid.ItemStyle.ForeColor = Color.Black
grid.BorderColor = Color.White
ClearControls(grid)
grid.RenderControl(hw)
' Write the HTML back to the browser.
HttpContext.Current.Response.Write(tw.ToString())
' End the response.
HttpContext.Current.Response.End()
Else

HttpContext.Current.Response.Write("Too many rows - Export to Excel not possible")
End If

End Sub
'-----------------------
Sub ClearControls(ByVal control As Control)
Dim i As Integer
For i = control.Controls.Count - 1 To 0 Step -1
ClearControls(control.Controls(i))
Next i

If TypeOf control Is System.Web.UI.WebControls.Image Then
control.Parent.Controls.Remove(control)
End If

If (Not TypeOf control Is TableCell) Then
If Not (control.GetType().GetProperty("SelectedItem") Is Nothing) Then
Dim literal As New LiteralControl
control.Parent.Controls.Add(literal)
Try
literal.Text = CStr(control.GetType().GetProperty("SelectedItem").GetValue(control, Nothing))
Catch
End Try
control.Parent.Controls.Remove(control)
Else
If Not (control.GetType().GetProperty("Text") Is Nothing) Then
Dim literal As New LiteralControl
control.Parent.Controls.Add(literal)
literal.Text = CStr(control.GetType().GetProperty("Text").GetValue(control, Nothing))
control.Parent.Controls.Remove(control)
End If
End If
End If
Return
End Sub 'ClearControls

Please Help...Confused | :confused:

Thanks,
Hetal Kamdar
GeneralNeed help with BULK INSERT statement Pin
codevbpvo15-Feb-05 7:18
codevbpvo15-Feb-05 7:18 
GeneralRe: Need help with BULK INSERT statement Pin
Dave Kreskowiak15-Feb-05 7:48
mveDave Kreskowiak15-Feb-05 7:48 
GeneralRe: Need help with BULK INSERT statement Pin
Anonymous15-Feb-05 8:02
Anonymous15-Feb-05 8:02 
GeneralRe: Need help with BULK INSERT statement Pin
codevbpvo15-Feb-05 8:16
codevbpvo15-Feb-05 8:16 
GeneralRe: Need help with BULK INSERT statement Pin
rwestgraham15-Feb-05 10:33
rwestgraham15-Feb-05 10:33 
GeneralRe: Need help with BULK INSERT statement Pin
codevbpvo15-Feb-05 12:12
codevbpvo15-Feb-05 12:12 
GeneralCreating New Tables for OLEDB Pin
Jimiisama15-Feb-05 4:19
Jimiisama15-Feb-05 4:19 
GeneralRe: Creating New Tables for OLEDB Pin
numbrel15-Feb-05 9:46
numbrel15-Feb-05 9:46 
GeneralPublishing reports(VB) online using ASP Pin
kebi15-Feb-05 1:11
kebi15-Feb-05 1:11 
GeneralRe: Publishing reports(VB) online using ASP Pin
Dave Kreskowiak15-Feb-05 4:35
mveDave Kreskowiak15-Feb-05 4:35 
GeneralRe: Publishing reports(VB) online using ASP Pin
kebi15-Feb-05 6:59
kebi15-Feb-05 6:59 
GeneralRe: Publishing reports(VB) online using ASP Pin
Dave Kreskowiak15-Feb-05 7:44
mveDave Kreskowiak15-Feb-05 7:44 
GeneralMaking a font bold at runtime Pin
ShawnW4564514-Feb-05 23:30
sussShawnW4564514-Feb-05 23:30 
GeneralRe: Making a font bold at runtime Pin
Just Greeky Creek15-Feb-05 0:41
Just Greeky Creek15-Feb-05 0:41 
GeneralRe: Making a font bold at runtime Pin
ShawnW4564515-Feb-05 1:24
sussShawnW4564515-Feb-05 1:24 
GeneralRe: Making a font bold at runtime Pin
Dave Kreskowiak15-Feb-05 4:34
mveDave Kreskowiak15-Feb-05 4:34 
Generalbackground image on tree and list view Pin
Rizwan Bashir14-Feb-05 21:42
Rizwan Bashir14-Feb-05 21:42 

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.