Change CSV export to UTF-8 without conversion
This commit is contained in:
@@ -386,7 +386,7 @@ Sub ExportMasterDetailData()
|
|||||||
savePath = savePath & ".csv"
|
savePath = savePath & ".csv"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Use constant for header
|
' Use constant for header (write as UTF-8 without conversion)
|
||||||
Dim csvContent As String
|
Dim csvContent As String
|
||||||
csvContent = CSV_HEADER & vbCrLf
|
csvContent = CSV_HEADER & vbCrLf
|
||||||
|
|
||||||
@@ -394,9 +394,7 @@ Sub ExportMasterDetailData()
|
|||||||
Dim r As Long
|
Dim r As Long
|
||||||
For r = 7 To lastDataRow
|
For r = 7 To lastDataRow
|
||||||
If Trim(ws.Cells(r, 3).Value) <> "" Then
|
If Trim(ws.Cells(r, 3).Value) <> "" Then
|
||||||
' CSV col1 -> C column
|
|
||||||
csvContent = csvContent & CleanCSVField(ws.Cells(r, 3).Value)
|
csvContent = csvContent & CleanCSVField(ws.Cells(r, 3).Value)
|
||||||
' CSV col2-11 -> G-P column
|
|
||||||
For j = 7 To 16
|
For j = 7 To 16
|
||||||
csvContent = csvContent & "," & CleanCSVField(ws.Cells(r, j).Value)
|
csvContent = csvContent & "," & CleanCSVField(ws.Cells(r, j).Value)
|
||||||
Next j
|
Next j
|
||||||
@@ -404,14 +402,14 @@ Sub ExportMasterDetailData()
|
|||||||
End If
|
End If
|
||||||
Next r
|
Next r
|
||||||
|
|
||||||
' Write file
|
' Write file as UTF-8 (no charset conversion)
|
||||||
Dim stream As Object
|
Dim stream As Object
|
||||||
Set stream = CreateObject("ADODB.Stream")
|
Set stream = CreateObject("ADODB.Stream")
|
||||||
stream.Type = 2
|
stream.Type = 2
|
||||||
stream.Charset = "shift_jis"
|
stream.Charset = "utf-8"
|
||||||
stream.Open
|
stream.Open
|
||||||
stream.WriteText csvContent, 1
|
stream.WriteText csvContent, 1
|
||||||
stream.SaveToFile savePath, 2
|
stream.SaveToFile savePath, -1
|
||||||
stream.Close
|
stream.Close
|
||||||
|
|
||||||
MsgBox "CSV export completed.", vbInformation
|
MsgBox "CSV export completed.", vbInformation
|
||||||
|
|||||||
Reference in New Issue
Block a user