C#简单读取xls文件

public void ReadFile(string filePath)

{

 string stringLine=string.Empty;

  int readLine=1;

  StreamReader sd=null;

 try

 {

    sd=new StreamReader(filePath,Encoding.GetEncoding("GB2312"));

 }

  catch

 {

  //异常抛出

  }

  stringLine=sd.ReadLine();

  while((stringLine=sd.ReadLine())!=string.Empty)

  {  

    if(stringLine.TrimEnd(',')==string.Empty)

    {   continue;}

    //读取到每行信息stringLine进行处理    

   }

}

posted @ 2017-03-21 20:32  墨羽1578  阅读(1087)  评论(0编辑  收藏  举报