使用vb.net将格式文件固定的(.txt)转换为ms excel(.xlsx) [英] Converting (.txt) fixed with format files into ms excel (.xlsx) using vb.net
问题描述
大家好
请协助您创建代码以使用vb.net将固定格式文件的(.txt)源代码转换为ms excel(.xlsx).
参见下面的源文件:
00001111110000001ACH
00001222220000001ACH
00001333330000001ACH
它必须使用数据将以下内容细分为excel中的列
代码(0,4)
序列(5,13)
索引(14,3)
(同样,在获取数据之前,我也不需要先创建列名)
请任何帮助将不胜感激.
问候
Ryan
Hi All
please could you assist in help me in creating a code to source a (.txt) fixed with format files into ms excel (.xlsx) using vb.net.
See below source file :
00001111110000001ACH
00001222220000001ACH
00001333330000001ACH
it must segment out the following into columns in excel with the data
Code (0,4)
Sequence (5,13)
Index (14,3)
(also not i need to create the column names first before sourcing the data)
Please any help would be appreciated.
regards
Ryan
推荐答案
要做的第一件事是记录一个宏,这样它就可以向您显示执行导入操作的代码.
开始宏记录,然后小心地转到数据"->复制".从文本导入,以启动导入向导.仔细设置您的选项以解析所需的数据(显然使用固定宽度),然后单击确定"导入数据.停止宏录制.
完成后,您可以按F11键打开VBA编辑器,然后查看编写的代码.您编写的任何VB.NET代码都将以此代码为模型.
THe first thing you do is to record a macro so it can show you what the code looks like to do an import.
Start the macro recording, then, CAREFULLY, go to Data -> Import from text, to start the import wizard. Set your options carefully to parse the data how you want it (using fixed width obviously), then click OK to import the data. Stop the macro recording.
When that''s done, you can hit F11 to open the VBA editor and see the code that was written. Any VB.NET code you write will be modeled after this code.
这篇关于使用vb.net将格式文件固定的(.txt)转换为ms excel(.xlsx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!