java解析word文档

java解析word文档,网上找的,都是转完了,就没事了。可是我们项目需要转换后,提取里面的数据,并存入到数据库,搞了半天也不能提取数据,先把问题放在这里,先看看word文档片段,前言,附录就不写了,只写两段,因为这里需要截取数据:

5.1.1    DMIC

<参数名称> DCS microcell threshold(DCS微蜂窝门限)

 

<功能描述>

使用此参数用GSM 1800GSM 1900小区中MS的最大传输功率定义微蜂窝的大小。如果设为36/33dBm那么不使用宏蜂窝和微蜂窝之间的共用部分。

<影响范围>

小区

<重要性>

一般

<取值范围>

GSM 1800: 0..36(dBm),步长 2 dBm

GSM1900: 0..32(dBm),步长2 dBm33 dBm

<缺省值>

24

<注意事项>

无。

<参数来源>  dcsMicrocellThreshold

 

<相关命令>

查看:EEO

修改:EEN

5.1.2    DEC

<参数名称> delay of HO and PC for emergency calls(紧急呼叫中切换和功率控制延迟)

<功能描述>

此参数可以暂时关闭紧急呼叫过程中的切换和功率控制以确保U-TDOA位置的准确性。

<影响范围>

BSC

<重要性>

一般

<取值范围>

0…10  步长1

<缺省值>

5

<注意事项>

无。

<参数来源>  delayHoPcEmergencyCalls

 

<相关命令>

查看EEO

修改EEN

 

 

1.使用jacob:只能是windows系统使用,

    下载zip包,解压,得到一个jar和一个dll,jar导入到项目,dll放到C:/WINDOWS/system32目录下  

  1. import com.jacob.activeX.ActiveXComponent;
  2. import com.jacob.com.Dispatch;
  3. import com.jacob.com.Variant;
  4. public class TestWord{
  5.     public static void main(String[] args){
  6.         System.out.println(ChageFormat("c://","test.doc"));
  7. }
  8. public static boolean ChageFormat (String FolderPath,String FileName){
  9.     
  10.         String FileFormat = "";
  11.         System.out.println(FolderPath);
  12.         FileFormat = FileName.substring(FileName.length()-4,FileName.length());
  13.         System.out.println(FileFormat);
  14.         
  15.         if(FileFormat.equalsIgnoreCase(".doc"))
  16.         {
  17.             String DocFile = FolderPath +"//"+ FileName;
  18.             System.out.println("word文件路径:"+DocFile);
  19.             //word文件的完整路径
  20.             String HtmlFile = DocFile.substring(0, (DocFile.length() - 4)) + ".txt";//要是用htm的,把这里改成.htm
  21.             System.out.println("htm文件路径:"+HtmlFile);
  22.             //html文件的完整路径
  23.             ActiveXComponent app = new ActiveXComponent("Word.Application");
  24.             //启动word
  25.             try
  26.             {
  27.                 app.setProperty("Visible"new Variant(false));
  28.                 //设置word程序非可视化运行
  29.                 Dispatch docs = app.getProperty("Documents").toDispatch();
  30.                 Dispatch doc = Dispatch.invoke(docs,"Open", Dispatch.Method, new Object[]{DocFile,new Variant(false), new Variant(true)}, new int[1]).toDispatch(); 
  31.                 //打开word文件
  32.                 Dispatch.invoke(doc,"SaveAs",Dispatch.Method, new Object[]{HtmlFile,new Variant(7)}, new int[1]);//需奥生成htm的话,改成 new Variant(8),把上面的.txt,改成.htm
  33.                 //作为htm格式保存文件
  34.                 Dispatch.call(doc, "Close",new Variant(false));
  35.                 //关闭文件
  36.             }
  37.             catch (Exception e)
  38.             {
  39.                 e.printStackTrace();
  40.             }
  41.             finally
  42.             {
  43.                 app.invoke("Quit"new Variant[] {});
  44.                 //退出word程序
  45.             }
  46.             //转化完毕
  47.             return true;
  48.         }
  49.         return false;
  50.     }
  51.  }

 

可以转htm和txt,下面还有转xml的

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值