none
請教輸出文字檔產生亂碼的問題 RRS feed

  • 問題

  • Dim reader As SqlCeDataReader
    Dim stream As StreamWriter = File.CreateText("\" & Replace(FileName, ".sdf", ".csv"))

    conn.Open()
                    reader = cmd(sav).ExecuteReader

                    Dim header As String = ""
                    For j As Integer = 0 To reader.FieldCount - 1
                        header &= reader.GetName(j) & ","
                    Next
                    stream.WriteLine(header)
                    Do While reader.Read
                        Dim ss As String = ""
                        For i As Integer = 0 To reader.FieldCount - 1
                            ss &= reader.Item(i).ToString & ","
                        Next
                        stream.WriteLine(ss)
                    Loop

    conn.Close()

     

    上面是我的部份程式碼

    產生的文字檔使用notepad 可以正常開啟,但是如果用excel開就會產生亂碼

    請教各位這個問題要如何避免

    2008年6月6日 下午 05:56

解答

所有回覆