通过VB.NET将阿拉伯语数据导出到Excel
在我的表单中,我有一个ListView,我想将其数据导出到Excel文件中。这是我的代码:通过VB.NET将阿拉伯语数据导出到Excel,vb.net,excel,Vb.net,Excel,在我的表单中,我有一个ListView,我想将其数据导出到Excel文件中。这是我的代码: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim csvFileContents As New System.Text.StringBuilder Dim CurrLine As String = S
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim csvFileContents As New System.Text.StringBuilder
Dim CurrLine As String = String.Empty
'Write out the column names as headers for the csv file.
For columnIndex As Int32 = 0 To ListView1.Columns.Count - 1
CurrLine &= (String.Format("{0};", ListView1.Columns(columnIndex).Text))
Next
'Remove trailing comma
csvFileContents.AppendLine(CurrLine.Substring(0, CurrLine.Length - 1))
CurrLine = String.Empty 'Write out the data.
For Each item As ListViewItem In ListView1.Items
For Each subItem As ListViewItem.ListViewSubItem In item.SubItems
CurrLine &= (String.Format("{0};", subItem.Text))
Next
'Remove trailing comma
csvFileContents.AppendLine(CurrLine.Substring(0, CurrLine.Length - 1))
CurrLine = String.Empty
Next
'Create the file.
Dim Sys As New System.IO.StreamWriter("D:\Test.csv")
Sys.WriteLine(csvFileContents.ToString)
Sys.Flush()
Sys.Dispose()
End Sub
代码工作正常,但当我打开文件时,阿拉伯数据没有正确复制,这就是它的外观:
نبيل;سي عÙ
我如何解决这个问题?谢谢你你找到解决方案了吗?@valter没有,我使用了编码,阿拉伯语显示正确,但我在Excel的一列中保存了所有数据。