Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过VB.NET将阿拉伯语数据导出到Excel_Vb.net_Excel - Fatal编程技术网

通过VB.NET将阿拉伯语数据导出到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

在我的表单中,我有一个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 = 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的一列中保存了所有数据。