永中Office二次开发_JAVA的二次开发2
2009-04-01 08:52
176 查看
概述:永中Office是使用JAVA开发,所以直接使用JAVA进行二次开发比较方便,但由于在客户端运行时一般使用VB、VC去调用,所以有必要将其封装成COM组件,以便其它语言调用。
今天继续先将JAVA的二次开发的第二部分调用实例进行说明:
(如果大家觉得好我就继续,如果觉得不好这第二篇文章就算结束了)
1.清除痕迹
2.在书签位置插入图片
3.在RANGE位置插入图片
4.书签位置插入文件
5.RANGE位置插入文件
6.插入表格
7.保护、解保护文档
今天继续先将JAVA的二次开发的第二部分调用实例进行说明:
(如果大家觉得好我就继续,如果觉得不好这第二篇文章就算结束了)
1.清除痕迹
public static boolean AcceptAllRevision(Document document) { document.acceptAllRevision(); return true; }
2.在书签位置插入图片
public static boolean InsertPicToBookmark(Document document, String bookMarkName, String picPath, float width, float height) { BookMark bk = document.getBookmarks().get(bookMarkName); if(bk == null) return false; InsertPicToTextRange(bk.getRange(), picPath, width, height, true); return true; }
3.在RANGE位置插入图片
public static boolean InsertPicToTextRange(TextRange range, String picPath, float width, float height, boolean isBefore) { if(width*height == 0) { if(isBefore) range.insertPictureBefore(picPath); else range.insertPictureAfter(picPath); } else { if(isBefore) range.insertPictureBefore(picPath, width, height); else range.insertPictureAfter(picPath, width, height); } return true; }
4.书签位置插入文件
public static boolean InsertFileToBookmark(Document document, String bookMarkName, String filePath) { String t = filePath.toLowerCase(); if(!(t.contains(".doc") || t.contains(".rtf") || t.contains(".eio") || t.contains(".eit") || t.contains(".txt"))) return false; BookMark bk = document.getBookmarks().get(bookMarkName); if(bk == null) return false; document.setOffset(bk.getEndPosition()); document.insertDocument(2, filePath, null); return true; }
5.RANGE位置插入文件
public static boolean InsertFileToTextRange(Document document, TextRange range, String filePath) { String t = filePath.toLowerCase(); if(!(t.contains(".doc") || t.contains(".rtf") || t.contains(".eio") || t.contains(".eit") || t.contains(".txt"))) return false; if(range==null) return false; document.setOffset(range.getEndOffset()); document.insertDocument(2, filePath, null); return true; }
6.插入表格
public static boolean InsertTableToDocument(Document document, TextRange range, String tableName, int rowCount, int columnCount) { if(range == null) return false; document.getTables().addTable(range, rowCount, columnCount, tableName, TableConstants.AUTOFIT_CONTENT, 0); return true; }
7.保护、解保护文档
public static boolean ProtectDocument(Document document, int protectType) { document.protect(protectType, DOCPASSWORD); return true; } public static boolean UnprotectDocument(Document document) { document.unprotect(DOCPASSWORD); return true; }
相关文章推荐
- 永中Office二次开发_JAVA的二次开发1
- 基于GSM MODEM短信猫二次开发说明和免费二次开发包提供C#、VC、Delphi、linx、JAVA、PB等语言源程序
- MAC下基于JAVA和Tomcat的微信二次开发环境配置
- vmware vsphere5 二次开发 API java python
- Java开发学习之道:Java开源项目源码阅读方法及二次开发方法
- TFS二次开发系列:八、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(二)
- java语言对arcgis进行二次开发
- JAVA:基于ARCGIS二次开发可视化开发环境搭建
- Java微信二次开发-微信企业号开发
- Java微信二次开发之5-消息的接收与响应,主动接收与被动接收的区别
- Java微信二次开发之10-解析接口中的消息创建时间CreateTime 并转换成需要的格式
- Java微信二次开发之14-自定义菜单及菜单响应事件的推送
- Java微信二次开发之17-再次使用百度翻译api超链接实现对文本内容翻译并推送
- TFS二次开发系列:三、TFS二次开发的第一个实例
- Java微信二次开发(三) Java微信各类型消息封装
- ArcSDE SDK For Java二次开发介绍、示例
- TFS二次开发系列:七、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)
- 微信公众平台二次开发JAVA
- java快速开发平台 二次开发 外包项目利器 springmvc SSM后台框架源码
- java二次开发 外包项目利器 springmvc SSM后台框架源码