由于OFFICE 2010的安装包比较庞大,如果仅仅为了在服务器中实现操作EXCEL,完全没有必要安装整个OFFICE,是否可以不装OFFICE也实现与OFFICE文件的互相操作呢?答案是肯定的,在SSIS中只要安装Microsoft Access 2010 数据库引擎可再发行程序包即可实现2010 Microsoft Office System 文件与非 Microsoft Office 应用程序之间传输数据,支持现有的 Microsoft Office 文件(例如 Microsoft Office Access 2010(*.mdb 和 *.accdb)文件和 Microsoft Office Excel 2010(*.xls、*.xlsx 和 *.xlsb)文件)与其他数据源(例如 Microsoft SQL Server)之间传输数据。还支持与现有文本文件建立连接。 此外,还会安装 ODBC 和 OLEDB 驱动程序,供应用程序开发人员在开发与 Office 文件格式连接的应用程序时使用。该安装包下载地址:http://www.microsoft.com/zh-cn/download/details.aspx?id=13255 。

本人负责年初已上线的BI项目,一部分数据是需要自动采集在Sharepoint 2010上的Excel文档库数据,但SSIS服务器并没有安装OFFICE,就是通过此组件实现互操作!对于简单的EXCEL直接通过数据流的方式实现,对于负责的EXCEL则通过脚本实现,具体如下:

1.简单的EXCEL,数据流的实现方式。

2.负责的EXCEL,主要通过脚本实现。

连接Excel并返回所有SHEET脚本示例如下:

string strConn, ls_pjname = string.Empty,strsqlconn=string.Empty;

            strConn = @"Provider=Microsoft.Ace.OleDb.12.0;Data Source="+@as_xlspath+";Extended Properties='Excel 12.0; HDR=NO;IMEX=1'";

            OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataTable sheetNames = conn.GetOleDbSchemaTable
(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
conn.Close();

对于表内的数据可以通过SQL语句进行,脚本示例如下:

 /// <summary>
/// 獲取Excel文件中指定Sheet的內容到DataSet,以Sheet名做DataTable名
/// </summary>
/// <param name="FileFullPath">Excel物理路径</param>
/// <param name="no_HDR">第一行不是標題:true;第一行是標題:false;</param>
/// <param name="SheetName">第一行不是標題:true;第一行是標題:false;</param>
/// <returns>DataSet</returns>
public static DataSet GetExcelToDataSet(string FileFullPath, bool no_HDR, string SheetName)
{
try
{
string strConn = GetExcelConnectionString(FileFullPath, no_HDR);
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter odda = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}]", SheetName), conn); //("select * from [Sheet1$]", conn);
odda.Fill(ds, SheetName);
conn.Close();
return ds;
}
catch (Exception ee)
{
throw new Exception(ee.Message);
}
}

通过SSIS可以实现很强大的ETL操作,但前提是根据需求,可能还需要安装一些额外的安装包或组件。

本博客为软件人生原创,欢迎转载,转载请标明出处:http://www.cnblogs.com/nbpowerboy/p/3387268.html 。演绎或用于商业目的,但是必须保留本文的署名软件人生(包含链接)。如您有任何疑问或者授权方面的协商,请给我留言。

http://www.amnxy.com/
http://www.amnxy.com/a/amanidongtai/
http://www.amnxy.com/a/changjianwenti/
http://www.amnxy.com/a/chenggonganli/
http://www.amnxy.com/a/fazhanzhanlue/
http://www.amnxy.com/a/fuwuzhichia/
http://www.amnxy.com/a/fuzhushebei/
http://www.amnxy.com/a/ganxishebei/
http://www.amnxy.com/a/gongsijiagou/
http://www.amnxy.com/a/hezuohuigu/
http://www.amnxy.com/a/hongganjishebei/
http://www.amnxy.com/a/jiamengliucheng/
http://www.amnxy.com/a/jiamengtiaojian/
http://www.amnxy.com/a/kaidianyihuo/
http://www.amnxy.com/a/kaidianzhidao/
http://www.amnxy.com/a/lianxiwomen/
http://www.amnxy.com/a/lirunfenxi/
http://www.amnxy.com/a/mendianfenbu/
http://www.amnxy.com/a/mendianyingxiao/
http://www.amnxy.com/a/mendianzhanshi/
http://www.amnxy.com/a/pinpaijianjie/
http://www.amnxy.com/a/pinpaiyoushi/
http://www.amnxy.com/a/sanxingdiananli/
http://www.amnxy.com/a/shenqingjiameng/
http://www.amnxy.com/a/shuixishebei/
http://www.amnxy.com/a/sixingdiananli/
http://www.amnxy.com/a/touzifangan/
http://www.amnxy.com/a/xiangmuyoushi/
http://www.amnxy.com/a/xingyedongtai/
http://www.amnxy.com/a/xinwenzixun/
http://www.amnxy.com/a/yinglimoshi/
http://www.amnxy.com/a/youhuizhengce/
http://www.amnxy.com/a/zhuanyepeixun/
http://www.amnxy.com/a/ziliaoxiazai/
http://www.amnxy.com/a/amanidongtai/20151109/10.html
http://www.amnxy.com/a/amanidongtai/20151109/11.html
http://www.amnxy.com/a/amanidongtai/20151109/12.html
http://www.amnxy.com/a/amanidongtai/20151109/13.html
http://www.amnxy.com/a/amanidongtai/20151109/14.html
http://www.amnxy.com/a/amanidongtai/20151109/6.html
http://www.amnxy.com/a/amanidongtai/20151109/7.html
http://www.amnxy.com/a/amanidongtai/20151109/8.html
http://www.amnxy.com/a/amanidongtai/20151109/9.html
http://www.amnxy.com/a/amanidongtai/20151115/105.html
http://www.amnxy.com/a/changjianwenti/20151208/161.html
http://www.amnxy.com/a/changjianwenti/20151208/162.html
http://www.amnxy.com/a/changjianwenti/20151208/163.html
http://www.amnxy.com/a/changjianwenti/20151208/164.html
http://www.amnxy.com/a/changjianwenti/20151208/165.html
http://www.amnxy.com/a/changjianwenti/20151208/166.html
http://www.amnxy.com/a/changjianwenti/20151208/167.html
http://www.amnxy.com/a/changjianwenti/20151208/168.html
http://www.amnxy.com/a/changjianwenti/20151208/169.html
http://www.amnxy.com/a/changjianwenti/20151210/199.html
http://www.amnxy.com/a/fuzhushebei/20151116/135.html
http://www.amnxy.com/a/fuzhushebei/20151116/141.html
http://www.amnxy.com/a/fuzhushebei/20151209/176.html
http://www.amnxy.com/a/ganxishebei/20151116/133.html
http://www.amnxy.com/a/ganxishebei/20151116/134.html
http://www.amnxy.com/a/ganxishebei/20151116/136.html
http://www.amnxy.com/a/ganxishebei/20151209/170.html
http://www.amnxy.com/a/ganxishebei/20151209/171.html
http://www.amnxy.com/a/hongganjishebei/20151209/172.html
http://www.amnxy.com/a/hongganjishebei/20151209/173.html
http://www.amnxy.com/a/hongganjishebei/20151209/174.html
http://www.amnxy.com/a/hongganjishebei/20151209/175.html
http://www.amnxy.com/a/kaidianyihuo/20151109/33.html
http://www.amnxy.com/a/kaidianyihuo/20151109/34.html
http://www.amnxy.com/a/kaidianyihuo/20151109/35.html
http://www.amnxy.com/a/kaidianyihuo/20151109/36.html
http://www.amnxy.com/a/kaidianyihuo/20151109/37.html
http://www.amnxy.com/a/kaidianyihuo/20151109/38.html
http://www.amnxy.com/a/kaidianyihuo/20151109/39.html
http://www.amnxy.com/a/kaidianyihuo/20151207/159.html
http://www.amnxy.com/a/kaidianyihuo/20151207/160.html
http://www.amnxy.com/a/kaidianyihuo/20151210/198.html
http://www.amnxy.com/a/kaidianyihuo/20151210/200.html
http://www.amnxy.com/a/lirunfenxi/20151109/21.html
http://www.amnxy.com/a/lirunfenxi/20151109/22.html
http://www.amnxy.com/a/lirunfenxi/20151109/23.html
http://www.amnxy.com/a/lirunfenxi/20151109/24.html
http://www.amnxy.com/a/lirunfenxi/20151109/25.html
http://www.amnxy.com/a/lirunfenxi/20151109/26.html
http://www.amnxy.com/a/lirunfenxi/20151205/150.html
http://www.amnxy.com/a/lirunfenxi/20151205/151.html
http://www.amnxy.com/a/lirunfenxi/20151205/152.html
http://www.amnxy.com/a/lirunfenxi/20151210/196.html
http://www.amnxy.com/a/mendianyingxiao/20151125/142.html
http://www.amnxy.com/a/mendianyingxiao/20151125/143.html
http://www.amnxy.com/a/mendianyingxiao/20151125/144.html
http://www.amnxy.com/a/mendianyingxiao/20151125/145.html
http://www.amnxy.com/a/mendianyingxiao/20151125/146.html
http://www.amnxy.com/a/mendianyingxiao/20151125/147.html
http://www.amnxy.com/a/mendianyingxiao/20151125/148.html
http://www.amnxy.com/a/mendianyingxiao/20151207/157.html
http://www.amnxy.com/a/mendianyingxiao/20151207/158.html
http://www.amnxy.com/a/mendianyingxiao/20151210/195.html
http://www.amnxy.com/a/mendianyingxiao/20151210/197.html
http://www.amnxy.com/a/mendianzhanshi/yizhanshixihu/
http://www.amnxy.com/a/qita/liansuozhongguo/
http://www.amnxy.com/a/sanxingdiananli/20151116/107.html
http://www.amnxy.com/a/sanxingdiananli/20151116/108.html
http://www.amnxy.com/a/sanxingdiananli/20151116/109.html
http://www.amnxy.com/a/sanxingdiananli/20151116/113.html
http://www.amnxy.com/a/sanxingdiananli/20151209/177.html
http://www.amnxy.com/a/shuixishebei/20151116/137.html
http://www.amnxy.com/a/sixingdiananli/20151109/27.html
http://www.amnxy.com/a/sixingdiananli/20151109/28.html
http://www.amnxy.com/a/sixingdiananli/20151109/29.html
http://www.amnxy.com/a/sixingdiananli/20151209/178.html
http://www.amnxy.com/a/sixingdiananli/20151210/179.html
http://www.amnxy.com/a/sixingdiananli/20151210/180.html
http://www.amnxy.com/a/sixingdiananli/20151210/181.html
http://www.amnxy.com/a/sixingdiananli/20151210/182.html
http://www.amnxy.com/a/sixingdiananli/20151210/183.html
http://www.amnxy.com/a/sixingdiananli/20151210/184.html
http://www.amnxy.com/a/sixingdiananli/20151210/185.html
http://www.amnxy.com/a/sixingdiananli/20151210/186.html
http://www.amnxy.com/a/sixingdiananli/20151210/187.html
http://www.amnxy.com/a/sixingdiananli/20151210/188.html
http://www.amnxy.com/a/sixingdiananli/20151210/189.html
http://www.amnxy.com/a/sixingdiananli/20151210/190.html
http://www.amnxy.com/a/sixingdiananli/20151210/191.html
http://www.amnxy.com/a/sixingdiananli/20151210/192.html
http://www.amnxy.com/a/sixingdiananli/20151210/193.html
http://www.amnxy.com/a/sixingdiananli/20151210/194.html
http://www.amnxy.com/a/touzifangan/20151115/80.html
http://www.amnxy.com/a/touzifangan/20151115/81.html
http://www.amnxy.com/a/touzifangan/20151115/82.html
http://www.amnxy.com/a/touzifangan/20151207/153.html
http://www.amnxy.com/a/touzifangan/20151207/154.html
http://www.amnxy.com/a/touzifangan/20151207/155.html
http://www.amnxy.com/a/touzifangan/20151207/156.html
http://www.amnxy.com/a/woyaojiameng/jiamengzhichi/
http://www.amnxy.com/a/xingyedongtai/20151115/106.html
http://www.amnxy.com/a/xingyedongtai/20151205/149.html
http://www.amnxy.com/a/amanirongyu/2015/1109/49.html
http://www.amnxy.com/a/amanirongyu/2015/1109/50.html
http://www.amnxy.com/a/amanirongyu/2015/1109/51.html
http://www.amnxy.com/a/amanirongyu/2015/1109/52.html
http://www.amnxy.com/a/amanirongyu/2015/1109/53.html

在没安装OFFICE的服务器SSIS中进行EXCEL的ETL操作!的更多相关文章

  1. 在MFC中对Excel的一些操作

    首先要在程序中加载CExcel.h和CExcel.cpp文件,这里面包装了很多函数和对Excel文件的操作,下面所有程序中的m_excel都是类CExcel的对象,如: private: _Appli ...

  2. vbs中对excel的常用操作

    使用QTP自动化测试中,用到对excel的读写操作,这里把一些常用对excel操作的方法进行了归纳,总结.(对excel格式设置的常用操作这里没有进行总结.) Function DataToExcel ...

  3. C# 未安装Office环境下使用NPOI导出Excel文件

    1.NuGet直接安装NPOI程序包: 2. using NPOI.XSSF.UserModel; 3.导出Excel代码: private void TsbExport2ExcelClick(obj ...

  4. C#中导出EXCEL服务器端不用安装OFFICE

    在实际开发过程中,有时候服务器端没安装OFFICE,你和服务器管理员去商量安装个OFFICE的时候,管理员很倔犟的不给你安装的时候,这个时候就可以考虑我这个方法是实现导出EXCEL了.如果你导出的EX ...

  5. ASP.NET导出Excel(利用NPOI和EPPlus库,无需安装Office)

    网上提供了很多Asp.net中操作Excel的方法,其中大部分是调用微软的Office组件,下面提供三个无须安装Office即可从Asp.net输出Excel的方法. 1 简单方法 //下面代码输出的 ...

  6. C# 创建Excel或需不安装Office

    第一种.Aspose.Cells.dll //如果需要饶过office Excel那么就看我最后的实现方法吧~! //我最后的实现是使用的第三方Aspose.Cells.dll //具了解这个dll一 ...

  7. asp.net中通过注册表来检测是否安装Office(迅雷/QQ是否已安装)

    原文  asp.net中通过注册表来检测是否安装Office(迅雷/QQ是否已安装) 检测Office是否安装以及获取安装 路径 及安装版本  代码如下 复制代码 #region 检测Office是否 ...

  8. 在 Linux 中安装 Lighttpd Web 服务器

    Lighttpd 是一款开源 Web 服务器软件.Lighttpd 安全快速,符合行业标准,适配性强并且针对高配置环境进行了优化.相对于其它的 Web 服务器而言,Lighttpd 占用内存更少:因其 ...

  9. Ubuntu腾讯云主机安装分布式memcache服务器,C#中连接云主机进行存储的示例

    Ubuntu腾讯云主机安装分布式memcache服务器,C#中连接云主机进行存储的示例(github代码:https://github.com/qq719862911/MemcacheTestDemo ...

随机推荐

  1. Qt学习笔记:Qt中使用Lua

    今天想在Qt中使用Lua进行数据操作 结果发现在Qt中使用Lua的文章较少,虽然很简单,但是还是写出来提供入门,顺便记录一下 我使用的是Qt Creator 3.4.2,用的是mingw4.9.2的编 ...

  2. Android 学习之--android多线程断点下载

    我们平时都用"迅雷"下载软件,当下载到一半的时候突然断网,下次开启的时候能够从上次下载的地方继续下载,而且下载速度很快,那么这是怎么做到的呢! 其实它的“快”其实就是多线程的下载实 ...

  3. php读取大文件的方法

    1.使用file 函数直接读取 $starttime = microtime_float(); ini_set('memory_limit','-1'); $file = "testfile ...

  4. [原创]Windows Phone SDK下载

    [原创]Windows Phone SDK下载 http://dev.windowsphone.com/zh-cn/downloadsdk

  5. Activiti 流程实例、任务、执行对象及相关的表

    一个流程中,流程实例只有一个,执行对象可以有多个(如果存在分支和聚合) SELECT * FROM activiti.act_ru_execution a;  #正在执行的执行对象表 SELECT * ...

  6. 连接UI到代码

    本章,你将连接FoodTracker应用程序的UI到代码并定义一些可执行的动作.当你完成时,你的应用程序将是这个样子: 学习目标在课程结束时,你将能够:1.解释一个storyboard中的场景和vie ...

  7. 使用6to5,让今天就来写ES6的模块化开发!

    http://es6rocks.com/2014/10/es6-modules-today-with-6to5/?utm_source=javascriptweekly&utm_medium= ...

  8. Scala 深入浅出实战经典 第45讲: scala中context bounds代码实例

    王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...

  9. puma vs passenger vs rainbows! vs unicorn vs thin 适用场景 及 performance

    ruby的几个web server,按照开发活跃度.并发方案及要点.适用场景等分析puma vs passenger vs rainbows! vs unicorn vs thin. 1. thin: ...

  10. mac下忘记mysql密码, 重新设置mysql密码

    step1: 苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server)step2:进入终端输入:cd /usr/local/m ...