jacob word竖排文字变横排

一列正常,两列需要修改

/**
* 处理表格文字方向   竖排文字变横排

* @param doc
*            WORD文件全路径
* @param tableIndex
*            第几个表格
     * @param cellRowIdx
*            第几行      
     * @param cellColIdx
*            第几列               
*/
public static String getTxtFromCell(Dispatch selection,Dispatch doc,int tableIndex, int cellRowIdx, int cellColIdx) {
//  System.out.println(tableIndex+cellRowIdx+cellColIdx);
// 所有表格
 Dispatch tables = Dispatch.get(doc, "Tables").toDispatch(); 
 // 要填充的表格
 Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex)).toDispatch();  
 Dispatch cell = Dispatch.call(table, "Cell", new Variant(cellRowIdx),new Variant(cellColIdx)).toDispatch();
 Dispatch Range=Dispatch.get(cell,"Range").toDispatch();
 String text=Dispatch.get(Range,"Text").toString();
 text = text.substring(0, text.length() - 2); // 去掉最后的回车符;
 char[] chars=text.toCharArray();
 String ret="";
 Dispatch.call(cell, "Select");
// Dispatch ret = Dispatch.get(selection, "Text").toDispatch();
ret= Dispatch.get(selection, "Orientation").toString();
if(ret.equals("9999999")){
Dispatch.put(selection, "Orientation", 0);
String str="";
for(char a:chars){
str=str+a+"\n" ;
}
str = str.substring(0, str.length() - 1);
Dispatch.put(selection, "Text", str);
System.out.println("---------");
}
 return ret;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值