将Excel单元格导出为单个文本文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将Excel单元格导出为单个文本文件相关的知识,希望对你有一定的参考价值。
This is modified from code found here: http://www.meadinkent.co.uk/XLexport-text1.htm and here: http://www.meadinkent.co.uk/XLexport-text2.htm
Sub ExportToTextFiles() Dim FirstRow As Integer, LastRow As Integer, MyFileName As String, MyRow As Integer, MyStr As String ' change these values to the start row and end row for your notes. ' if you have to use a range you'll need a double loop below FirstRow = 1 LastRow = 4 For MyRow = FirstRow To LastRow If DoesFileExist(MyFileName) = 0 Then Open MyFileName For Output As #1 ' create a new file and record if file does not exist Else Open MyFileName For Append As #1 ' append a record if file does already exist End If ' loop through each row of the table MyStr = Cells(MyRow, 1).Value Print #1, MyStr Close #1 Next MsgBox "Done" End Sub Function DoesFileExist(FileName As String) As Byte ' returns 1 if FileName exists, otherwise 0 DoesFileExist = 1 Else DoesFileExist = 0 End If End Function
以上是关于将Excel单元格导出为单个文本文件的主要内容,如果未能解决你的问题,请参考以下文章
如何设定PLSQL DEVELOPER导出的CSV文件中单元格格式为文本?
JAVA中导出Excel将全部单元格设置为文本样式,就是导出的没有数据的单元格类型的设置
java生成csv格式文件后,用excel打开,单元格显示问题