关于读取EXCEL记录并导入到数据库表中的问题(50分)

  • 主题发起人 主题发起人 malloc
  • 开始时间 开始时间
M

malloc

Unregistered / Unconfirmed
GUEST, unregistred user!
excel文件的记录如下:<br>item &nbsp;description quantity<br>11 &nbsp; &nbsp; fafafa &nbsp; &nbsp; &nbsp; 20<br>12 &nbsp; &nbsp; ewerwr &nbsp; &nbsp; &nbsp; 30<br>13 &nbsp; &nbsp; ewewrew &nbsp; &nbsp; &nbsp;15<br>....<br><br>数据库的hdinformation表记录。<br>Item &nbsp; vendor &nbsp;price &nbsp;LT<br>11 &nbsp; &nbsp; EWEW &nbsp; &nbsp;22 &nbsp; &nbsp; &nbsp;2<br>12 &nbsp; &nbsp; ERED &nbsp; &nbsp;20 &nbsp; &nbsp; &nbsp;5<br>13 &nbsp; &nbsp; FFDS &nbsp; &nbsp;40 &nbsp; &nbsp; &nbsp;10<br><br>..<br>要求导入excel文件,并和hdinformation表 的记录进行匹配。。<br>生成新的excel文件 ,内容字段如下:<br>item &nbsp;description quantity vendor &nbsp;price &nbsp;LT<br>11 &nbsp; &nbsp; fafafa &nbsp; &nbsp; &nbsp; 20 &nbsp; &nbsp; &nbsp;EWEW &nbsp; &nbsp;22 &nbsp; &nbsp; &nbsp;2<br>12 &nbsp; &nbsp; ewerwr &nbsp; &nbsp; &nbsp; 30 &nbsp; &nbsp; &nbsp;ERED &nbsp; &nbsp;20 &nbsp; &nbsp; &nbsp;5<br><br>。。。。<br>如何解决呢?
 
直接将两个表导入,再用关联语句查询出来不就可以了.<br>例如:导入的表名为A<br>语句就是:Select item, description, quantity, vendor, price, LT <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; From a <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Left Outer join hdinformation b &nbsp; &nbsp;on a.item =b.item
 
1.把原Excel复制一份另存为新Excel文件。<br>2.打开新Excel,用VBA方式操作Excel。<br>3.以新Excel文件的Item为索引,循环检索数据库,将结果写新Excel文件。<br>4.保存新Excel文件。<br>[:)]
 
后退
顶部