在SSIS中导入具有合并单元格的Excel

时间:2017-06-16 06:01:03

标签: sql sql-server excel ssis etl

我的问题是在读取具有合并/组合列单元格的excel文件时。例如,请阅读下面的Excel数据到数据库。

Excel输入:

+----+-------+---------+-------+
| ID |      NAME       | DEPT  |
+----+-------+---------+-------+
|    | FNAME | LNAME   |       |
+----+-------+---------+-------+
|  1 | Akil  | Tiwari  | IT    |
|  2 | Vinod | Rathore | IT    |
|  3 | Jatin | Khanna  | HR    |
|  4 | Divya | Kherde  | AD    |
|  5 | Amey  | Gauda   | FI    |
+----+-------+---------+-------+

预期的数据库输出:

+----+-------+---------+------+
| ID | FNAME |  LNAME  | DEPT |
+----+-------+---------+------+
|  1 | Akil  | Tiwari  | IT   |
|  2 | Vinod | Rathore | IT   |
|  3 | Jatin | Khanna  | HR   |
|  4 | Divya | Kherde  | AD   |
|  5 | Amey  | Gauda   | FI   |
+----+-------+---------+------+

1 个答案:

答案 0 :(得分:1)

只需连接您的Excel,Excel连接管理器就会像下面这样读取它:

+----+-------+---------+-------+
| ID | NAME  | F3      | DEPT  |  <-- Header
+----+-------+---------+-------+
|    | FNAME | LNAME   |       |  <--First Row
+----+-------+---------+-------+
|  1 | Akil  | Tiwari  | IT    |  <-- Second Row
|  2 | Vinod | Rathore | IT    |   .
|  3 | Jatin | Khanna  | HR    |   .
|  4 | Divya | Kherde  | AD    |   .
|  5 | Amey  | Gauda   | FI    |   .
+----+-------+---------+-------+

在Excel源中只需重命名列如下“

NAME --> FNAME
F3   --> LNAME

enter image description here

然后添加一个条件性拆分,使用以下表达式

过滤ID = NULL的行
ISNULL([ID]) == false

enter image description here

然后第一行将被忽略