首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >使用csv/excel数据自动设置文本格式

使用csv/excel数据自动设置文本格式
EN

Stack Overflow用户
提问于 2016-11-30 19:27:07
回答 1查看 67关注 0票数 0

我要找一个软件,可以输出从excel表格/ csv的每一行单独的文本文件。我想为dokuwiki创建多个文本文件。csv中的数据将填充预格式化的文本文件模板。

我相信我可以写一个python脚本,可以做到这一点,但我想知道是否有软件可以使这项任务更快,更好,更容易。

EN

回答 1

Stack Overflow用户

发布于 2016-11-30 20:30:42

这就是你要找的东西吗?

代码语言:javascript
代码运行次数:0
运行
复制
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

最后,您可以关闭而不保存。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40887195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档