各位大哥:       现在我在做一个windows应用程序.客户提出导入txt文件后,文件的数据内容显示出来,(显出出来的数据应该类似于excel文件那样有规则),并可编辑,然后再导出成excel文件。请问这一过程如何实现。
小弟对各位的意见不胜感激!

解决方案 »

  1.   

    导入txt文件 txt原本里面是什么样式  打开就什么样式
                  string str;
                openPicture.Filter = "文本文件(*.txt)|*.txt";
                if (openPicture.ShowDialog() == DialogResult.OK && openPicture.FileName.Length > 0)
                {
                    str = openPicture.FileName;                FileStream fs = new FileStream(str, FileMode.Open, FileAccess.Read);
                    StreamReader m_streamReader = new StreamReader(fs);
                    //使用StreamReader类来读取文件
                      m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                    // 从数据流中读取每一行,直到文件的最后一行,并在TextBox1中显示出内容
                      this.TextBox1.Text = "";
                    string strLine = m_streamReader.ReadLine();
                    while (strLine != null)
                    {
                        this.TextBox1.Text += strLine + "\n";
                        strLine = m_streamReader.ReadLine();
                    }
                    //关闭此StreamReader对象
                       m_streamReader.Close();
                }
    导出execl 我有上传一个dll文件 上面有操作方法
    下载位置:http://download.csdn.net/source/323234