zoukankan      html  css  js  c++  java
  • excel导入DataTable

    http://www.cnblogs.com/top5/archive/2010/03/12/1684559.html

    --下载excel的dll

    http://bbs.csdn.net/topics/390271458

    http://zhidao.baidu.com/link?url=c1m-oJjceP0oXP7_Hlm2EyoD9F71SVmlERMX3pPDSRgiKJxeIaoZV0xav9jxdJm04ibUB5h05k1wi8Hjl45O6q

    excel 导入到datatable

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.Office.Interop.Excel;
    using System.IO;
    using System.Reflection;
    using System.Data.OleDb;
    
     private void Bingdgv()
            {
                if (FilePath == "")
                {
                    return;
                }
                try
                {
                    OleDbConnection conn = new OleDbConnection(ExcelConnStr);
                    string sql = "select * from [Sheet1$]";
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    OleDbDataAdapter myCommand = new OleDbDataAdapter(sql, conn);
                    ds = new DataSet();
                    myCommand.Fill(ds, "[Sheet1$]");
                    conn.Close();
    
                    dgvData.DataMember = "[Sheet1$]";
                    dgvData.DataSource = ds;
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    throw ex;
                }
            }

    “System.Data.DataTable”和“Microsoft.Office.Interop.Excel.DataTable”之间的不明确的引用

    DataTable dt=new DataTable();了吗??
    引用了 uisng System.Data;吗??
    using Excel = Microsoft.Office.Interop.Excel;
    这样就OK了,呵呵
  • 相关阅读:
    521.最长特殊序列 I
    520.检查大写字母
    459.重复的子字符串
    Java 读取 .properties 文件的几种方式
    Idea 使用教程
    db2 with用法
    DB2 alter 新增/删除/修改列
    Bootstrap treegrid 实现树形表格结构
    Mysql 递归查询
    navicat for mysql 下载安装教程
  • 原文地址:https://www.cnblogs.com/jcz1206/p/4320647.html
Copyright © 2011-2022 走看看