Click here to Skip to main content
15,919,879 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionusing sleep method in vb.net Pin
solarthur0110-Dec-07 13:09
solarthur0110-Dec-07 13:09 
GeneralRe: using sleep method in vb.net Pin
Christian Graus10-Dec-07 16:59
protectorChristian Graus10-Dec-07 16:59 
QuestionHelp:How to add a disclaimer to outgoing smtp messages? Pin
Member 466244410-Dec-07 13:02
Member 466244410-Dec-07 13:02 
GeneralRe: Help:How to add a disclaimer to outgoing smtp messages? Pin
CKnig10-Dec-07 18:26
CKnig10-Dec-07 18:26 
GeneralNeed some help with VB.Net Code Behind and Gridviews Pin
Coleenh10-Dec-07 12:36
Coleenh10-Dec-07 12:36 
GeneralRe: Need some help with VB.Net Code Behind and Gridviews Pin
Michael Sync10-Dec-07 20:16
Michael Sync10-Dec-07 20:16 
GeneralRe: Need some help with VB.Net Code Behind and Gridviews Pin
Coleenh11-Dec-07 7:47
Coleenh11-Dec-07 7:47 
GeneralConvert DataGrid into Excel Pin
M_Menon10-Dec-07 7:13
M_Menon10-Dec-07 7:13 
Hi Friends,
I am trying to Convert DataGrid into Excel,
My Code -------------------------------

Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
'export to excel

Response.Clear()

Response.Buffer = True

Response.ContentType = "application/octet-stream"
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")

'Response.ContentType = "application/vnd.ms-excel"

Response.Charset = ""

Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter

Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

grd1.AllowPaging = False

Me.ClearControls(grd1)

grd1.RenderControl(oHtmlTextWriter)Response.Write(oStringWriter.ToString())Response.End()
End Sub

Private 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 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

I am getting output of Excel. But not in correct format. The Excel sheet contains data of only the First page. It shows the Paging Number down after the first 10 records. And yes i have a column of data in Greek language which is not visible clearly. I am using MS Office 2007. Any help or suggestions would be highly appreciated.

Thanks

Cheers

Menon

GeneralVB.Net and VB6 Pin
manisghouri10-Dec-07 7:00
manisghouri10-Dec-07 7:00 
GeneralRe: VB.Net and VB6 Pin
Christian Graus10-Dec-07 8:23
protectorChristian Graus10-Dec-07 8:23 
GeneralRe: VB.Net and VB6 Pin
manisghouri10-Dec-07 22:41
manisghouri10-Dec-07 22:41 
GeneralBalloon Tooltip Dose not Work Pin
shamsoft10-Dec-07 6:59
shamsoft10-Dec-07 6:59 
GeneralDetermine all downloading is complete or not Pin
Rupesh Kumar Swami10-Dec-07 5:53
Rupesh Kumar Swami10-Dec-07 5:53 
GeneralRe: Determine all downloading is complete or not Pin
Christian Graus10-Dec-07 8:25
protectorChristian Graus10-Dec-07 8:25 
GeneralRe: Determine all downloading is complete or not Pin
Rupesh Kumar Swami11-Dec-07 3:01
Rupesh Kumar Swami11-Dec-07 3:01 
Questiondataview.rowfilter not filtering Pin
DBND10-Dec-07 5:12
DBND10-Dec-07 5:12 
GeneralGDI+ Error Pin
The ANZAC10-Dec-07 1:35
The ANZAC10-Dec-07 1:35 
GeneralRe: GDI+ Error Pin
Luc Pattyn10-Dec-07 2:15
sitebuilderLuc Pattyn10-Dec-07 2:15 
GeneralRe: GDI+ Error Pin
The ANZAC10-Dec-07 15:46
The ANZAC10-Dec-07 15:46 
GeneralRe: GDI+ Error Pin
Luc Pattyn10-Dec-07 16:10
sitebuilderLuc Pattyn10-Dec-07 16:10 
GeneralRe: GDI+ Error Pin
The ANZAC10-Dec-07 17:50
The ANZAC10-Dec-07 17:50 
GeneralRe: GDI+ Error Pin
Dave Kreskowiak10-Dec-07 2:16
mveDave Kreskowiak10-Dec-07 2:16 
GeneralRe: GDI+ Error Pin
Christian Graus10-Dec-07 8:26
protectorChristian Graus10-Dec-07 8:26 
GeneralRe: GDI+ Error Pin
Dave Kreskowiak10-Dec-07 12:05
mveDave Kreskowiak10-Dec-07 12:05 
GeneralRe: GDI+ Error Pin
Christian Graus10-Dec-07 12:28
protectorChristian Graus10-Dec-07 12:28 

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.