码迷,mamicode.com
首页 > 其他好文 > 详细

点击按钮,导入excel

时间:2014-07-28 23:39:04      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:io   cti   ar   new   res   table   file   log   

需为2003版本

 private void button1_Click(object sender, EventArgs e)
        {
            string resultFile = "";
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = "D:";
            openFileDialog1.Filter = "All files (*.*)|*.*|xls files (*.txt)|*.xls";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.Multiselect = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                resultFile = openFileDialog1.FileName;

            }
            if (resultFile == "")
            { }
            else
            {
                dt = FunctionExcel.ExcelToDataTable(resultFile, "Sheet1");

                dgv_Data.DataSource = dt;
            }
        }

DataTable dt_new = new DataTable();
            dt_new = dgv_Data.DataSource as DataTable;

点击按钮,导入excel,布布扣,bubuko.com

点击按钮,导入excel

标签:io   cti   ar   new   res   table   file   log   

原文地址:http://www.cnblogs.com/alina-he/p/3873243.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!