本文介绍了将Excel数据写入Txt文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在宏中,我打开了一个新的文本文件,并将数据从excel工作表复制到该文本文件.它工作正常,并且我也在文本文件中获取数据.但是........
格式不整齐,例如
名字姓氏
鲍勃·约翰
Qwak水晶
但我要这样
名字姓氏
鲍勃·约翰
Qwak水晶
即使我尝试在单词之间插入空格(例如5个空格),一行与另一行的格式也不同,请给这个建议......
In a macro I have opened a new text file and copying data from excel sheet to that text file.It is working fine and i am getting data in the text file also.But........
The format is not in Good order,like
FirstName LastName
Bob John
Qwak crystal
But i want in this manner
FirstName LastName
Bob John
Qwak crystal
Even if i try to insert spaces also (Eg 5 spaces)between words,The format of one row to other row is different,Plz Give suggestions for this...........
推荐答案
''sValue=text of your cell
''sPad_Text=padding character - " " in most cases
''sType="Left"|"Right"
''iMaxSize=desired width of field (greater than maximum size)
Public Function pad(svalue, spad_text, stype, imaxsize)
Dim length
length = Len(svalue)
If stype = "Left" Then
pad = String(imaxsize - length, spad_text) & svalue
Else
pad = svalue & String(imaxsize - length, spad_text)
End If
End Function
这篇关于将Excel数据写入Txt文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!