如何为每行excel数据输出文件?现在它输出正确数量的文件,但数据行增加,因此文件1正确,文件2有行1和行2等。
Dim smNum As Integer = 0
If rowct > 0 Then
For rr As Integer = 10 To rowct
For cc As Integer = 1 To colct
val = CType(r.Cells(rr, cc), Excel.Range).Value
If val = "" Then Exit For
str.Append(ht((cc - 1).ToString)).Append(",")
str.Append(val)
'assigning the sample managaer num in column 1
If cc = 1 Then
smNum = val
file_name = selectedFile.Substring(13, 16) & "_" & smNum & "_" & todays_date & file_count & ".csv"
full_path = save_file_path & file_name
MessageBox.Show("Sample Manager Number: " & val & full_path)
End If
If cc < colct Then
str.Append(",")
End If
My.Computer.FileSystem.WriteAllText(full_path, str.ToString, False)
lstFileOut.Items.Add(file_name)
Next
'str.AppendLine()
Next
End If
答案 0 :(得分:2)