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
        }

    }
  • 相关阅读:
    人脸识别数据库
    美赛
    排序算法
    个人作业——软件工程实践总结作业
    事后诸葛亮(团队)
    个人作业——软件产品案例分析
    Alpha冲刺总结
    Alpha冲刺——Day2
    Alpha冲刺——Day1
    I Know Alpha冲刺随笔集
  • 原文地址:https://www.cnblogs.com/lpe110/p/718423.html
Copyright © 2011-2022 走看看