Problem when exporting datagridview to csv

  • Thread starter Thread starter monemas
  • Start date Start date
M

monemas

Guest
hi

I have a problem when exporting datagridview to a csv file .
Where the datagridview, the second column contains an encoded font name "AlmaFont"
The export is fine, but the font does not appear in the csv file

1- What I want is the font change in the csv file = "AlmaFont"
2-Is there a possibility to set a style for the head columns when opening the file in an Excel format?

my code to export to csv

Dim thecsvfile As String = String.Empty
For Each column As DataGridViewColumn In DATAG_CLIEN.Columns
thecsvfile = thecsvfile & column.HeaderText & ","
Next
thecsvfile = thecsvfile.TrimEnd(",")
thecsvfile = thecsvfile & vbCr & vbLf
'get the rows
For Each row As DataGridViewRow In DATAG_CLIEN.Rows
'get the cells
For Each cell As DataGridViewCell In row.Cells
thecsvfile = thecsvfile & cell.FormattedValue.replace(",", "") & ","
Next
'trim the last comma
thecsvfile = thecsvfile.TrimEnd(",")
'Add the line to the output
thecsvfile = thecsvfile & vbCr & vbLf
Next
My.Computer.FileSystem.WriteAllText("D:\New folder\export.csv", thecsvfile, False)

Continue reading...
 
Back
Top