从文本文件中读取内容并以给定格式写入excel [英] Read Contents from text file and write to excel with given format
问题描述
我有一项任务是从文本文件中读取内容并使用下面给出的相同列值写入excel;
输入文件:(。txt文件)
----------
水果:苹果
蔬菜:胡萝卜
车辆:汽车
性别:男
年龄:25
------------------
水果:芒果
蔬菜:番茄
车辆:公共汽车
性别:FeMale
部门:IT
----------- ------
输出:.xls
---------------- ---------------------------------
水果蔬菜车性别年龄段>> ;>>>>>>> Excel列名
-------------------------- -----------------------
Apple Carrot Car男25 -
芒果番茄巴士女 - 它
注:
每条记录都以超线(---)结尾文本文件。
某些列不会出现在文本文件中,如果文本文件中有任何新列需要附加到excel文件中,
请给出解决方案。
谢谢,
SK
< blockquote>使用 Interop [ ^ ],你只需做3件事: br />
1)导入文本文件,使用 OpenText [ ^ ]方法,
)将行转置为列,将数据复制到剪贴板和使用转置选项 [ ^ ],
3)删除重复的列标题
请试试。这很简单;)
对于编写Excel文件,您可以使用Open XML SDK。格式本身可用,并根据ECMA-376和ISO / IEC 29500:2008标准化:
http: //en.wikipedia.org/wiki/Office_Open_XML [ ^ ],
http://en.wikipedia.org/wiki/Office_Open_XML_software [ ^ ]。
请参阅Office Open XML软件的对比图表:
http://en.wikipedia .org / wiki / Comparison_of_Office_Open_XML_software [ ^ ]。
这是另一种选择: http:// n poi.codeplex.com/ [ ^ ]。
-SA
它不是那样的工作。
我们不要为你工作。
如果你想让别人写你的代码,你必须付钱 - 我建议你去VWorker.com并在那里问。
但要注意:你得到的是你付出的代价。支付花生,获得猴子
Hi,
I have a task to read the contents from text file and write to excel with same column- values as given below;
Input file: (.txt file)
----------
Fruit:Apple
Vegetable:Carrot
Vehicle:Car
Gender:Male
Age: 25
------------------
Fruit:Mango
Vegetable:Tomato
Vehicle:Bus
Gender:FeMale
Dept: IT
-----------------
Output: .xls
-------------------------------------------------
Fruit Vegetable Vehicle Gender Age Dept >>>>>>>>Excel Column Names
-------------------------------------------------
Apple Carrot Car Male 25 -
Mango Tomato Bus Female - IT
Note:
Each record ends with hypen line (---) in the text file.
Some column will not appear in the text file and if any new column in text file then need to append in excel file,
Please give a solution.
Thanks,
SK
Using Interop[^], you need to do only 3 things:
1) import text file, using OpenText[^] method,
2) transpose rows to columns, copying data into clipboard and pasting it with transpose option[^],
3) remove duplicated column-headers
Please, try. It's really easy ;)
For writing Excel file, you can use Open XML SDK. The format itself is available and is standardized under ECMA-376 and ISO/IEC 29500:2008:
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://en.wikipedia.org/wiki/Office_Open_XML_software[^].
Please see the comparison chart on Office Open XML software:
http://en.wikipedia.org/wiki/Comparison_of_Office_Open_XML_software[^].
This is another option: http://npoi.codeplex.com/[^].
—SA
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to VWorker.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys
这篇关于从文本文件中读取内容并以给定格式写入excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!