在没安装OFFICE的服务器SSIS中进行EXCEL的ETL操作!
由于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操作!的更多相关文章
- 在MFC中对Excel的一些操作
首先要在程序中加载CExcel.h和CExcel.cpp文件,这里面包装了很多函数和对Excel文件的操作,下面所有程序中的m_excel都是类CExcel的对象,如: private: _Appli ...
- vbs中对excel的常用操作
使用QTP自动化测试中,用到对excel的读写操作,这里把一些常用对excel操作的方法进行了归纳,总结.(对excel格式设置的常用操作这里没有进行总结.) Function DataToExcel ...
- C# 未安装Office环境下使用NPOI导出Excel文件
1.NuGet直接安装NPOI程序包: 2. using NPOI.XSSF.UserModel; 3.导出Excel代码: private void TsbExport2ExcelClick(obj ...
- C#中导出EXCEL服务器端不用安装OFFICE
在实际开发过程中,有时候服务器端没安装OFFICE,你和服务器管理员去商量安装个OFFICE的时候,管理员很倔犟的不给你安装的时候,这个时候就可以考虑我这个方法是实现导出EXCEL了.如果你导出的EX ...
- ASP.NET导出Excel(利用NPOI和EPPlus库,无需安装Office)
网上提供了很多Asp.net中操作Excel的方法,其中大部分是调用微软的Office组件,下面提供三个无须安装Office即可从Asp.net输出Excel的方法. 1 简单方法 //下面代码输出的 ...
- C# 创建Excel或需不安装Office
第一种.Aspose.Cells.dll //如果需要饶过office Excel那么就看我最后的实现方法吧~! //我最后的实现是使用的第三方Aspose.Cells.dll //具了解这个dll一 ...
- asp.net中通过注册表来检测是否安装Office(迅雷/QQ是否已安装)
原文 asp.net中通过注册表来检测是否安装Office(迅雷/QQ是否已安装) 检测Office是否安装以及获取安装 路径 及安装版本 代码如下 复制代码 #region 检测Office是否 ...
- 在 Linux 中安装 Lighttpd Web 服务器
Lighttpd 是一款开源 Web 服务器软件.Lighttpd 安全快速,符合行业标准,适配性强并且针对高配置环境进行了优化.相对于其它的 Web 服务器而言,Lighttpd 占用内存更少:因其 ...
- Ubuntu腾讯云主机安装分布式memcache服务器,C#中连接云主机进行存储的示例
Ubuntu腾讯云主机安装分布式memcache服务器,C#中连接云主机进行存储的示例(github代码:https://github.com/qq719862911/MemcacheTestDemo ...
随机推荐
- JavaScript中的property和attribute
property,attribute都作“属性”解,但是attribute更强调区别于其他事物的特质/特性. 而在JavaScript中,property和attribute更是有明显的区别.众所周知 ...
- MongoDB与.NET结合使用二(安全)
真实的部署环境为了防止外部攻击,肯定是要修改端口和设置用户账号保护数据的安全性,这一篇文章重点来设置这些内容. Mongodb中mongo.exe 是客户端测试程序,mongod.exe为服务器端程序 ...
- clientHeight,offsetHeight与scrollHeight的相关知识
在html里,width与height是最常用也是最基础的两个属性,因此,在js里,我们也经常需要操作这两个属性.js关于这两个属性提供了client*,offset*与scroll*,很多同学搞不清 ...
- .net对象序列化解析
一.二进制格式器(Binary Formatter) vs XML格式器(XML Formatter): 下面我先向大家介绍两种不同的格式器,分别用它们如何实现序列化机制和反序列化机制,请看下面的代码 ...
- Atitit. js mvc 总结(2)----angular 跟 Knockout o99 最佳实践
Atitit. js mvc 总结(2)----angular 跟 Knockout o99 最佳实践 1. 框架 angular 跟Knockout 1 2. 2. 简单的列表绑定:Knockou ...
- iOS开发拓展篇——如何把项目托管到GitHub
iOS开发拓展篇——如何把项目托管到GitHub 说明:本文主要介绍如何把一个OC项目托管到Github,重操作轻理论. 第一步:先注册一个Github的账号,这是必须的 注册地址:Github官网注 ...
- iOS7隐藏状态栏 statusBar
转:http://blog.csdn.net/dqjyong/article/details/17896145 评:通过这点变化,可以看出苹果倾向于使用delegate取代全局变量. IOS7中,不仅 ...
- 【Android开发坑系列】之PopupWindow
PopupWindow在4.0之前的版本有个系统级别的BUG,必须借助一段自定义的fix代码来修复.其中mPopPm就是PopupWindow实例.java.lang.NullPointerExcep ...
- mysql触发器_begin end 执行多次语句
//多SQL中导出的触发器语句: DROP TRIGGER IF EXISTS `t_trig`; DELIMITER // CREATE TRIGGER `t_trig` BEFORE INSERT ...
- String和包装类Integer\Double\Long\Float\Character 都是final类型
String和包装类Integer\Double\Long\Float\Character\Boolean 都是final类型 不可以改变