.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
    }

}
原文地址:https://www.cnblogs.com/lpe110/p/718423.html