日期:2014-05-17  浏览次数:20795 次

java实现htm文件转换为Excel文件
需求:上传htm文件(Excel另存为的文件),按照配置的行,列把数据导入到数据库。其中存在合并单元格
我的想法是,上传后转换为Excel文件,然后用poi操作。
大鸟帮忙解决下,别的解决思路也行,谢谢。
------解决方案--------------------
你现在的流程是:
上传html——解析html——插入Excel——解析Excel——插入数据库

你解析的Excel数据如果跟解析的html数据没啥子区别,我认为还是变一变
上传html——解析html——插入Excel——插入数据库

内容已经解析过了,就不要在解析一次了吧!
------解决方案--------------------
上传html???哪如果要修改数据的话,是去修改html代码???如果你只是要入库的话那就直接解析html中的xml,为什么还要经过excel呢....


------解决方案--------------------
回复于: 2014-01-16 18:03:38
直接解析html插入数据库不就完了
------解决方案--------------------
引用:
需求:上传htm文件(Excel另存为的文件),按照配置的行,列把数据导入到数据库。其中存在合并单元格
我的想法是,上传后转换为Excel文件,然后用poi操作。
大鸟帮忙解决下,别的解决思路也行,谢谢。


我的想法是,上传后转换为Excel文件,然后用poi操作。

这个思路不错  楼主可以试试
------解决方案--------------------
引用:
Quote: 引用:

既然是XML,为什么要弄成excel呢,解析XML→封装信息成对象→插入数据库

并不是严格意义上的XML,文本打开部分内容如下:
<tr height=20 style='mso-height-source:userset;height:15.0pt'>
  <td height=20 class=xl96 style='height:15.0pt'>21200632801</td>
  <td class=xl94> </td>
  <td class=xl94>G109</td>
  <td class=xl94>青藏线</td>
  <td class=xl153 x:num>3671</td>
  <td class=xl152 x:num>3672</td>
  <td class=xl141 x:num>1000</td>
  <td class=xl94>上行</td>
  <td class=xl95>沥青</td>
  <td class=xl99 width=42 style='width:32pt' x:num>82.5</td>
  <td class=xl100 width=42 style='width:32pt' x:num>82.8</td>
  <td class=xl100 width=42 style='width:32pt' x:num>95</td>
  <td class=xl100 width=42 style='width:32pt' x:num>60</td>
  <td class=xl100 width=42 style='width:32pt'> </td>
  <td class=xl92></td>
 </tr>
 <tr height=20 style='mso-height-source:userset;height:15.0pt'>
  <td height=20 class=xl96 style='height:15.0pt'>21200632801</td>
  <td class=xl94> </td>
  <td class=xl94>G109</td>
  <td class=xl94>青藏线</td>
  <td class=xl153 x:num>3672</td>
  <td class=xl152 x:num>3673</td>
  <td class=xl141 x:num>1000</td>
  <td class=xl94>上行</td>
  <td class=xl95>沥青</td>
  <td class=xl99 width=42 style='width:32pt' x:num>85.9</td>
  <td class=xl100 width=42 style='width:32pt' x:num>83.7</td>
  <td class=xl100 width=42 style='width:32pt' x:num>70</td>
  <td class=xl100 width=42 style='width:32pt' x:num>100</td>
  <td class=xl100 width=42 style='width:32pt'> </td>
&nb