我需要解析Excel工作表。现在我将每个单独的工作表保存为.csv,它的效果很好。我使用OpenCSV解析文件等,但创建这些.csv文件是一个痛苦。
I need to parse Excel work sheets. Now I save each individual work sheet as .csv and it works great. I use OpenCSV to parse the files etc. but to create those .csv files are a pain.
将个别工作表保存为最简单,最快捷的方法是什么? csv在Excel中?我假设某种VBA宏会做这个工作,但由于我不是VBA程序员,我不知道该怎么做。也许我只能记录一个宏?
What would be the easiest and quickest way to save individual work sheets as .csv in Excel? I am assuming some kind of VBA macro would do the job, but since I am not a VBA programmer I have no idea how to do it. Maybe I can just record a macro somehow?
推荐答案非常粗略的
Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets ws.SaveAs "C:\docs\" & ws.Name & ".csv", xlCSV Next这不包括任何错误编码允许将导致非法文件名的工作表名称。这一切都取决于你需要的整体情况。
This does not include any error coding nor does it make allowances for sheet names that will lead to illegal file names. It all depends on how robust you need the whole thing to be.
更多推荐
将单独的Excel工作表另存为CSV
发布评论