| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4907 人关注过本帖
标题:帮看看 问题出在哪了啊~求高手
只看楼主 加入收藏
viskin
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-11-22
收藏
 问题点数:0 回复次数:0 
帮看看 问题出在哪了啊~求高手
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
using Tekla.Structures.Model;
using Tekla.Structures;
using Tekla.Structures.Model.UI;
namespace BEAM_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog diolog = new OpenFileDialog();
            diolog.Filter = "Excel 文件(*xls)|*xls";
            diolog.FileName = "";
            if (diolog.ShowDialog() == DialogResult.OK)
            {
                string PathString = diolog.FileName.Trim();
                this.listView1.Items.Clear();
                string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source =" + PathString + ";" + "Extended Properties=;'Excel 8.0;HDR=NO;IMEX=1';";
                String strExcel = "select*from[sheet1$]";
                OleDbConnection conn = null;
                try
                {
                    conn = new OleDbConnection(strConn);
                    conn.Open();
                    OleDbCommand cmd = new OleDbCommand(strExcel, conn);
                    OleDbCommand reas = cmd.ExecuteReader();
                  
                    while (reas.Read())
                    {
                        string CeLingDH = reas[0].ToString();
                        string strAssNum = reas[1].ToString();
                        string strParNum = reas[2].ToString();
                        string strSize = reas[3].ToString();
                        string strMaterial = reas[4].ToString();
                        string strGrade = reas[5].ToString();
                        ListViewItem lv = new ListViewItem(CeLingDH);
                        lv.SubItems.Add(strAssNum);
                        lv.SubItems.Add(strParNum);
                        lv.SubItems.Add(strSize);
                        lv.SubItems.Add(strMaterial);
                        lv.SubItems.Add(strGrade);
                        listView1.Items.Add(lv);

                    }
                }
                catch (OleDbException ex)
                {
                    MessageBox.Show("打开错误!" + ex.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
搜索更多相关主题的帖子: public 
2014-11-22 15:15
快速回复:帮看看 问题出在哪了啊~求高手
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038861 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved