我要找一个软件,可以输出从excel表格/ csv的每一行单独的文本文件。我想为dokuwiki创建多个文本文件。csv中的数据将填充预格式化的文本文件模板。
我相信我可以写一个python脚本,可以做到这一点,但我想知道是否有软件可以使这项任务更快,更好,更容易。
发布于 2016-11-30 12:30:42
这就是你要找的东西吗?
Sub aru()
Dim row As Long
Dim lastrow As Long
Dim i As Long
Dim file As Worksheet
Dim col As Long
Dim lastcol As Long
Dim dir As String
Application.DisplayAlerts = False
dir = "C:\txt\" 'Set here the folder you want to save the files
i = 1
lastrow = Cells(Rows.count, 1).End(xlUp).row
For row = 1 To lastrow 'Define here the starting row
lastcol = Cells(row, Columns.count).End(xlToLeft).Column
Sheets.Add.Name = "File" & i
Set file = Sheets("File" & i)
For col = 1 To lastcol
file.Cells(1, col).Value = Cells(row, col).Value
Next col
file.SaveAs dir & file.Name & ".csv", xlCSV
i = i + 1
file.Delete
Next row
Application.DisplayAlerts = True
End Sub
最后,您可以关闭而不保存。
https://stackoverflow.com/questions/40887195
复制