OpenOffice java api UNO 设置属性总结

本文介绍使用Java编程操作OpenOffice文档的方法,包括设置文本样式、段落对齐、表格边框等属性。提供了具体示例代码,适用于需要批量编辑文档的场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一. 重要的属性设置的java代码  

1) 设置不显示虚框。一般用来 解决利用表格进行布局 时候不显示虚框的问题。(虚框怎么设置参考4)

              PropertyValue[] loadProps = new PropertyValue[1];

 

loadProps[0] = new PropertyValue();

// 是否显示虚框

loadProps[0].Name = "isRasterVisible";

loadProps[0].Value = new Boolean(true);

2)  设置字体名称(亚洲,还有其他),字体大小

 

xCursorProps.setPropertyValue("CharFontNameAsian", "新宋体");

xCursorProps.setPropertyValue("CharHeightAsian", new Float(10.5));

xCursorProps.setPropertyValue("CharFontName", "Arial");

xCursorProps.setPropertyValue("CharHeight", new Float(10.5));

3)设置行据为150mm

 

LineSpacing lineSpacing = new LineSpacing();

lineSpacing.Mode = LineSpacingMode.PROP;

lineSpacing.Height = 150;

xCursorProps.setPropertyValue("ParaLineSpacing", lineSpacing);

 

 

 

 

4)设置表格所有边框为虚框.

TableBorder tableBorder = new TableBorder();

tableBorder.IsBottomLineValid = true;

tableBorder.IsLeftLineValid = true;

tableBorder.IsRightLineValid = true;

tableBorder.IsTopLineValid = true;

tableBorder.IsHorizontalLineValid = true;

tableBorder.IsVerticalLineValid = true;

xTableProps.setPropertyValue("TableBorder", tableBorder);

5)设置表格中字体的是否是黑体, 对齐方式。

xCellCursorProps.setPropertyValue("CharWeightAsian", new Float(0.0));

xCellCursorProps.setPropertyValue("CharWeight", new Float(0.0));

// 左对齐

xCellCursorProps.setPropertyValue("ParaAdjust", com.sun.star.style.ParagraphAdjust.LEFT);

6) 设置段落对齐方式为两端对齐

XPropertySet xWordProps = (XPropertySet) UnoRuntime.queryInterface(

XPropertySet.class, xWordCursor);

xWordProps.setPropertyValue("ParaAdjust",

com.sun.star.style.ParagraphAdjust.BLOCK);

   (ps: 段落的对齐方式,所以要划分好doc中的段落)

 

 

二.解决openOffice java 编程的方法

枚举吧,首先要看官方手册,明白了大致怎么个代码流程就可以打开doc,设置属性,然后goolge,baidu.

http://hi.baidu.com/zzeric/blog/item/84bdd28bc34be7dffd1f10cd.html

这个一个所有属性的列表. 

最后一个很重要的论坛:http://user.services.openoffice.org/  各种语言!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值