zoukankan      html  css  js  c++  java
  • Excel exportExcelDAL

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.OleDb;

    namespace DAL
    {
      public    class exportExcelDAL
        {
       
          /// <summary>
          /// 执行Sql命令
          /// </summary>
          /// <param name="strCommand"></param>
          /// <param name="DataSource"></param>
          /// <returns></returns>
          public System.Data.DataTable exeCommand(string strCommand, string DataSource)
          {
              //strCommand = "SELECT " + strSelect + "FROM [" + strTableName + "$] " + strWhere + " " + strOrderBy;
              string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataSource + ";" + "Extended Properties=Excel 8.0;";
              System.Data.DataTable dt = null;
              try
              {
                  using (OleDbConnection objConn = new OleDbConnection(sConnectionString))
                  {
                      dt = new System.Data.DataTable();
                      objConn.Open();
                      OleDbDataAdapter adapter = new OleDbDataAdapter(strCommand, objConn);
                      dt = new System.Data.DataTable();
                      adapter.Fill(dt);
                  }
              }
              catch (Exception)
              {
              }
              return dt;
          }

        }
    }

  • 相关阅读:
    Largest Rectangle in Histogram
    Valid Sudoku
    Set Matrix Zeroes
    Unique Paths
    Binary Tree Level Order Traversal II
    Binary Tree Level Order Traversal
    Path Sum II
    Path Sum
    Validate Binary Search Tree
    新手程序员 e
  • 原文地址:https://www.cnblogs.com/heling/p/1667463.html
Copyright © 2011-2022 走看看