Add ReadCSVFileWithUtf8 and use it in Z1

This commit is contained in:
updsv7
2026-04-13 19:00:50 +09:00
parent 5c739dfe55
commit c482518135
2 changed files with 23 additions and 1 deletions

View File

@@ -129,3 +129,25 @@ Sub WriteCSVFile(ByVal filePath As String, ByVal content As String)
.Close .Close
End With End With
End Sub End Sub
Function ReadCSVFileWithUtf8(ByVal filePath As String) As Variant
If filePath = "" Then
ReadCSVFileWithUtf8 = Array()
Exit Function
End If
Dim stream As Object
Dim textContent As String
Set stream = CreateObject("ADODB.Stream")
With stream
.Type = 2
.Charset = "utf-8"
.Open
.LoadFromFile filePath
textContent = .ReadText
.Close
End With
ReadCSVFileWithUtf8 = Split(textContent, vbLf)
End Function

View File

@@ -19,7 +19,7 @@ Sub Z1_ImportMasterDetailData()
If filePath = "" Then Exit Sub If filePath = "" Then Exit Sub
' Step 2: Read CSV ' Step 2: Read CSV
lines = ReadCSVFile(filePath) lines = ReadCSVFileWithUtf8(filePath)
' Step 3: Validate column count ' Step 3: Validate column count
If Not ValidateCSVColumnCount(lines, 7) Then Exit Sub If Not ValidateCSVColumnCount(lines, 7) Then Exit Sub