用c# 将txt转换为excel
我的txt如下:
39.4% 2013-07-03 15-38-59
35.8 2013-07-03 15-38-59
39.5% 2013-07-03 15-39-03
35.8 2013-07-03 15-39-03
39.7% 2013-07-03 15-39-06
35.7 2013-07-03 15-39-06
39.8% 2013-07-03 15-39-10
35.6 2013-07-03 15-39-10
......
想分为四列
39.4% 2013-07-03 15-38-59 35.8 2013-07-03 15-38-59
39.5% 2013-07-03 15-39-03 35.8 2013-07-03 15-39-03
39.7% 2013-07-03 15-39-06 35.7 2013-07-03 15-39-06
39.8% 2013-07-03 15-39-10 35.6 2013-07-03 15-39-10
........
请问该怎么做?最好用代码教我与给出具体实现。网上的小工具转化都做不到这种程度。
------解决方案--------------------就上转换格式这一部分的代码,生成到excel,自己百度下或者参考我的博客:
生成excel
string result = string.Empty;
StreamReader sr = new StreamReader("test.txt");
int line = 0;
while (sr.Peek() > 0)
{
line++;
result += sr.ReadLine() + " ";
if (line % 2 == 0)
{
result += "\r\n";
}
}
Console.WriteLine(result);