zoukankan      html  css  js  c++  java
  • .NET 中将Excel 文件导入到SQLSERVER

        首先要说一下自己写的一个帮助类ExcelHelper。可以用两种方式访问Excel文件,一种是以ExcelCom组件的形式,一种是最简单的把Excel看作是数据库。
      using
     System;
    using
     System.IO;
    using
     System.Collections;
    using
     System.Text;

    using
     System.Data;
    using
     System.Data.OleDb;

    namespace
     com.urp.command.FileFrameWork.Helper
    {
        
    /// <summary>
        
    /// Class1 的摘要说明。
        
    /// </summary>

        public class ExcelHelper
        
    {
            
    private readonly string readConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source={0};"

                
    +"Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'";

            
    private readonly string writeConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source={0};"

                
    +"Extended Properties='Excel 8.0;HDR=YES;'"
            
            
    private OleDbConnection _conn = null
    ;
            
    private OleDbCommand _command = null
    ;
            
    private OleDbDataAdapter _adapter = null
    ;
            
    private OleDbCommandBuilder _builder = null
    ;

            
    private Excel.Application _application =  null
    ;
            
    private Excel._Workbook _workBook = null
    ;
            
    private Excel._Worksheet _workSheet = null
    ;
            
    private Excel.Range _range =  null
    ;

            
    private int
     _columnCount;
            
    private int
     _rowCount;

            
    private object _missingValue =
     System.Reflection.Missing.Value;

            
    public ExcelHelper(string
     path)
            


            
    public ExcelHelper()
            


            
    ComExcel

            
    ADO.Net
        }

    }
  • 相关阅读:
    迈安
    sql 迈安
    Python开发环境02 Windows平台命令行方式
    Python开发环境01 Mac平台命令行方式
    Python简史03 Python启示录
    Python简史02 Python的诞生
    Python简史01 Python的起源
    图书爬虫的进展
    爬虫方面的进展
    最近的进展
  • 原文地址:https://www.cnblogs.com/lpe110/p/718423.html
Copyright © 2011-2022 走看看