zoukankan      html  css  js  c++  java
  • Excel转DataSet的一个例子

    public   static  DataSet ExcelToDS( string  Pathm, string  TableName)
            
    {
                DataSet ds 
    =   new  DataSet();
                
    try
                
    {
                    
    string  strConn  =   " Provider=Microsoft.Jet.OLEDB.4.0; "   +   " Data Source= "   +  Path  +   " ; "   +   " Extended Properties=Excel 8.0; " ;
                    OleDbConnection conn 
    =   new  OleDbConnection(strConn);
                    conn.Open();
                    
    string  strExcel  =   "" ;
                    OleDbDataAdapter myCommand 
    =   null ;
                    strExcel 
    =   string .Format( " select * from [{0}$] " ,TableName);
                    myCommand 
    =   new  OleDbDataAdapter(strExcel, strConn);

                    myCommand.Fill(ds, TableName);
                }

                
    catch (Exception ex)
                
    {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }

                
    return  ds;
            }
     
  • 相关阅读:
    form 编译命令
    Form文件夹开发步骤
    使用View为Data Source的Form开发要点
    spring2.0包说明【转】
    Zero to One读后感
    Fourth glance in Go
    Third glance in Go
    Second glance in Go
    First glance in Go
    MongoDB 安装
  • 原文地址:https://www.cnblogs.com/cl1024cl/p/6204976.html
Copyright © 2011-2022 走看看