使用SSIS,我可以使用OLE将带有喷气驱动程序读取Excel或我可以使用“Excel连接”SSIS Excel源连接。它用什么来读取Excel?
的一个单独的连接类型两者似乎有问题,阅读文件与合并的细胞,为我担心。
我很好奇当使用“Excel连接”时,SSIS使用什么来连接Excel。
除了VBA之外,对于阅读已在服务器上合并单元格,公式,格式等的Excel文件,您会有什么建议?我使用Excel 2003中
更新
下面是我用来读取XLS代码:
private static void GetExcelSheets(string filePath)
{
string connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'", filePath, "no");
OleDbConnection excelConnection = new OleDbConnection(connectionString);
OleDbCommand cmdExcel = new OleDbCommand();
OleDbDataAdapter oda = new OleDbDataAdapter();
cmdExcel.Connection = excelConnection;
if (excelConnection.State == ConnectionState.Open)
{
excelConnection.Close();
}
excelConnection.Open();
OleDbCommand oleDbCommand = new OleDbCommand();
oleDbCommand.CommandType = System.Data.CommandType.Text;
oleDbCommand.Connection = excelConnection;
OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(oleDbCommand);
DataTable dtExcelSheetName = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string getExcelSheetName = dtExcelSheetName.Rows[5]["Table_Name"].ToString();
oleDbCommand.CommandText = "SELECT * FROM [" + getExcelSheetName + "]";
oleDbDataAdapter.SelectCommand = oleDbCommand;
DataTable dtExcelRecords = new DataTable();
oleDbDataAdapter.Fill(dtExcelRecords);
excelConnection.Dispose();
}
当我看到一个电子表格,看起来像这样:
然后使用调试器Visualizer来显示数据集,我看到这个。请注意,在源电子表格,我盘旋数据从数据表显示丢失:
至于有关使用Microsoft OLE DB提供程序为Jet 4.0 Excel连接点。在SSIS中,有两个独立的连接对象。第一个是Excel Connect对象。它的属性页面如下所示:
第二个是使用JET驱动程序并指向Excel的OLE连接对象。
是Excel的Connection对象确实使用了4.0的Jet驱动程序,它是做同样的事情只是一个速记方式或者是这些conenction类型确实在某些方面有什么不同?
请参阅我的更新。 – ChadD
@ChadD:不幸的是,我在一个阻止imgur链接的企业网络中,所以我看不到你的截图;当我回到家时,我会尽量跟进。 –