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
        }

    }
  • 相关阅读:
    黑马程序员java笔记之五泛型
    黑马程序员java笔记之六网络编程
    黑马程序员java笔记之四IO流
    黑马程序员java笔记之九交通灯信号管理系统
    黑马程序员java笔记之一Map集合
    黑马程序员java笔记之十银行管理系统
    Create a secure MapGuide Site创建安全的MapGuide站点
    SQL Server 2008 and Visual Studio 2008 Service Pack 1 Available for Download
    VS2008不著名的bug
    varchar(MAX)SQL2005的增强特性
  • 原文地址:https://www.cnblogs.com/lpe110/p/718423.html
Copyright © 2011-2022 走看看