从txt文件里读取指定的数据,保存到excel中解决方案

从txt文件里读取指定的数据,保存到excel中
_|10|MP Noise PK2PK|383|3.14|1000|0|-
_|11|MP Low Roll Off Setup|0|0.53075|0|0|
_|12|MP Low Roll Off FFT Peak|532|17.35888|998|400|-
_|13|MP Low Roll Off FFT Ratio|1064|0.01525|10000|100|-
_|14|MP Pass Band Setup|0|0.531|0|0|
_|15|MP Pass Band FFT Peak|711|16.56212|998|475|-
_|16|MP Pass Band FFT Ratio|115|0.015375|10000|100|-
_|17|MP High Roll Off Setup|0|0.546125|0|0|
_|18|MP High Roll Off FFT Peak|462|16.62462|998|300|-
_|19|MP High Roll Off FFT Ratio|99|0.015375|10000|80|-
如上所述,做一个数据统计,编个c++程序,把第一行383数据,第三行532数据和第六行711数据分别保存到excel三列中,刚开始接触编程,不知道从哪怎么下手,请各位帮帮忙,指点一下,谢谢!!
------解决方案--------------------
  TStringList * strs = new TStringList;
  strs->LoadFromFile(L"x.txt");


------解决方案--------------------
最简单的就是用stringlist吧。stringlist里load然后用另外一个stringlist来用
------解决方案--------------------
分割数据。
------解决方案--------------------
用TStringList 分解字符串。保存Excel文件的方法参考
http://blog.163.com/strawberry0924@126/blog/static/21870833200762091733789/
------解决方案--------------------
引用:
int line_count;
line_count = pFileText->Count;
for (int i = 0; i < line_count; i++) {
String sline;//类对象
String sData_Int = L"";这个L""是什么?
bool is_first_data = false;
sline = pFileText->Strings[……

L表示转换成Unicode 双字符编码
if (sline != L"")//这句是什么意思? 表示这一行不为空
//还有这个,pos是string的函数?但是前面怎么int pos;呢?    pos是定义的一个整形变量,
STRING.POS()是STRING类中的一个函数,pos用来储存STRING.POS()的返回值


------解决方案--------------------
OLE专业户来也!!!
完整代码实现楼主需求。

#include <stdio.h>
#include <tchar.h>

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    // 用来保存需要读取的三个数字
    int nResult1, nResult2, nResult3;

    // 两个字符串列表对象,用来读取源文件和分析行数据
    TStringList *lstFile = new TStringList;

    // 读入源文件
    lstFile->LoadFromFile("D:\\ccrun\\aaa.txt");
    // 你要读取1,3,6行的数据,如果文件不足6行,似乎不是你需要的文件
    if (lstFile->Count < 6)
    {
        delete lstFile;

        return;
    }

    int a, n;
    char sz1[512], sz2[512];
    memset(sz1, 0x0, sizeof(sz1));
    memset(sz2, 0x0, sizeof(sz2));

    // 分析第一行的数据
    // _
------解决方案--------------------
10
------解决方案--------------------
MP Noise PK2PK
------解决方案--------------------
383
------解决方案--------------------
3.14
------解决方案--------------------
1000
------解决方案--------------------
0
------解决方案--------------------
-
    n = _stscanf(lstFile->Strings[0].c_str(), TEXT("_
------解决方案--------------------
%d
------解决方案--------------------
%[^'
------解决方案--------------------
']
------解决方案--------------------
%d
------解决方案--------------------
%s"), &a, sz1, &nResult1, sz2);
    if (n != 4) nResult1 = 0;

    // 分析第三行的数据
    // _
------解决方案--------------------
12
------解决方案--------------------
MP Low Roll Off FFT Peak
------解决方案--------------------
532
------解决方案--------------------
17.35888
------解决方案--------------------
998
------解决方案--------------------
400
------解决方案--------------------
-
    n = _stscanf(lstFile->Strings[2].c_str(), TEXT("_
------解决方案--------------------
%d
------解决方案--------------------
%[^'
------解决方案--------------------
']
------解决方案--------------------
%d
------解决方案--------------------
%s"), &a, sz1, &nResult2, sz2);
    if (n != 4) nResult2 = 0;

    // 分析第六行的数据
    // _
------解决方案--------------------
15
------解决方案--------------------