将单独的Excel工作表另存为CSV

编程入门 行业动态 更新时间:2024-10-26 13:20:54
本文介绍了将单独的Excel工作表另存为CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要解析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

本文发布于:2023-10-26 11:45:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:另存为   工作   Excel   CSV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!