Click here to Skip to main content
16,006,768 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: how to play sound in vb.net? Pin
Chandana Subasinghe7-Mar-06 4:19
Chandana Subasinghe7-Mar-06 4:19 
GeneralRe: how to play sound in vb.net? Pin
campbells7-Mar-06 5:38
campbells7-Mar-06 5:38 
QuestionTreeview problem in vb.net Pin
pankajgarg127-Mar-06 3:01
pankajgarg127-Mar-06 3:01 
AnswerRe: Treeview problem in vb.net Pin
Chandana Subasinghe7-Mar-06 4:34
Chandana Subasinghe7-Mar-06 4:34 
GeneralRe: Treeview problem in vb.net Pin
pankajgarg127-Mar-06 21:47
pankajgarg127-Mar-06 21:47 
QuestionChanging datagrid properties like column header text,width,alignment at runtime Pin
hisuman1007-Mar-06 2:10
hisuman1007-Mar-06 2:10 
AnswerRe: Changing datagrid properties like column header text,width,alignment at runtime Pin
Dave Kreskowiak7-Mar-06 5:11
mveDave Kreskowiak7-Mar-06 5:11 
QuestionExport DataGridView to Excel (xls) format Pin
veljkoz7-Mar-06 0:39
veljkoz7-Mar-06 0:39 
Hi!
I need to export data contained in the DataGridView control to Excel. The code provided here does the work, but not fully - when Excel opens the file, it recognises it like a "Tab delimited values" and import wizard appears. This is too complicated for (my) end users, so I need a way to write "real" xls file, without the need of end user action. Do you know how can I do this?

The code is:
'(tab is DataGridView control containing data)

Dim fileText As System.Text.StringBuilder = New System.Text.StringBuilder()

'exporting column names
For Each col As DataGridViewColumn In tab.Columns
If col.Visible = True Then
fileText.Append(col.Name)
fileText.Append(vbTab)
End If
Next
fileText.Append(vbCrLf)

'export cell values
For Each row As DataGridViewRow In tab.Rows
For Each theCell As DataGridViewCell In row.Cells
If theCell.Visible = True Then
fileText.Append(theCell.Value.ToString())
fileText.Append(vbTab)
End If
Next
fileText.Append(vbCrLf) 'moving to the next row
Next

My.Computer.FileSystem.WriteAllText("Test.xls", fileText.ToString(), False)

Any help would be appreciated!
Thank you in advance!
Veljko


AnswerRe: Export DataGridView to Excel (xls) format Pin
Bulbul Bhuwania7-Mar-06 1:23
Bulbul Bhuwania7-Mar-06 1:23 
GeneralRe: Export DataGridView to Excel (xls) format Pin
veljkoz7-Mar-06 2:27
veljkoz7-Mar-06 2:27 
AnswerRe: Export DataGridView to Excel (xls) format Pin
mayhem_rules7-Mar-06 1:31
mayhem_rules7-Mar-06 1:31 
GeneralRe: Export DataGridView to Excel (xls) format Pin
albCode7-Mar-06 3:32
albCode7-Mar-06 3:32 
GeneralRe: Export DataGridView to Excel (xls) format Pin
veljkoz7-Mar-06 3:48
veljkoz7-Mar-06 3:48 
GeneralRe: Export DataGridView to Excel (xls) format Pin
albCode7-Mar-06 4:12
albCode7-Mar-06 4:12 
QuestionSet the diabled text field color? Pin
cylix20006-Mar-06 23:40
cylix20006-Mar-06 23:40 
AnswerRe: Set the diabled text field color? Pin
Bulbul Bhuwania7-Mar-06 0:08
Bulbul Bhuwania7-Mar-06 0:08 
GeneralRe: Set the diabled text field color? Pin
Bulbul Bhuwania7-Mar-06 0:10
Bulbul Bhuwania7-Mar-06 0:10 
GeneralRe: Set the diabled text field color? Pin
Bulbul Bhuwania7-Mar-06 0:11
Bulbul Bhuwania7-Mar-06 0:11 
AnswerRe: Set the diabled text field color? Pin
sathish s7-Mar-06 0:56
sathish s7-Mar-06 0:56 
AnswerRe: Set the diabled text field color? Pin
jcrussell7-Mar-06 13:42
jcrussell7-Mar-06 13:42 
QuestionVB dll.......bulbul Pin
Paritos6-Mar-06 23:02
Paritos6-Mar-06 23:02 
AnswerRe: VB dll.......bulbul Pin
Vasudevan Deepak Kumar6-Mar-06 23:05
Vasudevan Deepak Kumar6-Mar-06 23:05 
GeneralRe: VB dll.......bulbul Pin
Bulbul Bhuwania6-Mar-06 23:49
Bulbul Bhuwania6-Mar-06 23:49 
GeneralRe: VB dll.......bulbul Pin
Paritos6-Mar-06 23:50
Paritos6-Mar-06 23:50 
GeneralRe: VB dll.......bulbul Pin
Bulbul Bhuwania6-Mar-06 23:57
Bulbul Bhuwania6-Mar-06 23:57 

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.