将Excel文件保存为制表符分隔的文本文件,不带引号
我有一个 Excel 2010 工作簿。我需要将每个工作表的使用范围保存为制表符分隔的文本文件,不带引号,文件名与工作簿相同,扩展名由工作表名称指定。
请注意,只要 Excel 看到逗号,就会愚蠢地用引号将值括起来,即使分隔符是制表符;除此之外,正常的“另存为”/“文本(制表符分隔)”就可以了。
我更愿意使用 Excel 中的 VBA 代码来完成此操作。
如果有Python解决方案,我也会感兴趣。但目前 pywin32 对 Python 3 的支持还只是实验性的,所以我不确定我是否可以使用它。
I have an Excel 2010 workbook. I need to save the used range of each of its worksheets as a tab-delimited text file with no quotes, with the same filename as the workbook and with an extension given by the worksheet name.
Note that Excel stupidly surrounds a value by quotes whenever it sees a comma, even though the delimiter is a tab; other than that, the normal "Save As" / "Text (Tab delimited)" would be fine.
I would prefer to do that using VBA code from within Excel.
If there is a Python solution, I'd be interested too. But at this point pywin32 support for Python 3 is only experimental, so I am not sure I can use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,这是一个稍微复杂的例程,是我几个月前为我的一位客户写的。此代码将 Excel 工作表导出到不带引号的固定宽度文件。还附上了屏幕截图。我相信这段代码可以做得更好:)
经过尝试和测试
Ok here is a slightly complex routine which I wrote couple of months back for one of my clients. This code exports the Excel Worksheet to a Fixed Width File without QUOTES. Screenshots also attached. I am sure this code can be made even better :)
TRIED AND TESTED
打开您的 Excel/csv/文本
执行您所需的操作,然后您可以使用文件格式另存为 xlTextPrinter
ActiveWorkbook.SaveAs Filename:="Your File Name.txt", FileFormat:=xlTextPrinter, CreateBackup:=False
不需要额外的代码来替换额外的引号
Open your excel/csv/text
Perform your your required action and then You can saveas using file format as xlTextPrinter
ActiveWorkbook.SaveAs Filename:="Your File Name.txt", FileFormat:=xlTextPrinter, CreateBackup:=False
No need for extra code to replace extra quotes