Java中itemOpen,OpenOffice java api UNO 设置属性总结

简单备份一些重要的属性设置的java代码  和 解决openOffice java 编程的方法:

一. 重要的属性设置的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.

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值