- 浏览: 308482 次
- 性别:
- 来自: 成都
文章分类
- 全部博客 (118)
- VS2008 (2)
- JAVA (34)
- AJAX (1)
- C# (1)
- Flex (16)
- FMS (6)
- SQLSERVER (1)
- ORACLE (1)
- Quartz (1)
- struts2 (1)
- java数据结构 (1)
- java设计模式 (3)
- JSF (0)
- web (2)
- jbpm4 (4)
- J2EE (1)
- webservice (2)
- javascript (8)
- spring (3)
- lucene (0)
- linux (9)
- ibatis (1)
- JPA (2)
- 外挂 (0)
- VB (0)
- Hibernate (1)
- OSGI (8)
- EXT (4)
- Maven (1)
- SpringSecurity (0)
- activiti (0)
- 项目开发 (0)
- 项目管理 (7)
- android (0)
- FFMPEG (1)
- C (2)
- eclipse (1)
最新评论
-
默默得守候在你的身边:
给力
java与Delphi写的dll交互 -
默默得守候在你的身边:
java与Delphi写的dll交互 -
fuguitong:
[url][url][url][url][url][url][ ...
doc转swf -
baidu_25402161:
到结束的时候一直 Can't delete processIn ...
一个请假单流程的实现(struts2.1.8+spring2.5+hibernate3集成jbpm4.3) -
lohaoo1:
nice!
java面包屑导航制作
package org.foreverframework.office; import java.io.File; public class MSWordUtil { private static final String COLUMNS = "Columns"; private static final String CELLS = "Cells"; private static final String ROWS = "Rows"; private static final String COUNT = "Count"; private static final String TABLES = "Tables"; private static final String ITEM = "Item"; private static final String CELL = "Cell"; private static final String RANGE = "Range"; private static final String TOP = "Top"; private static final String LEFT = "Left"; private static final String Z_ORDER = "ZOrder"; private static final String CONVERT_TO_SHAPE = "ConvertToShape"; private static final String HEIGHT = "Height"; private static final String WIDTH = "Width"; private static final String ADD_PICTURE = "AddPicture"; private static final String INLINE_SHAPES = "InlineShapes"; private static final String MATCH_ALL_WORD_FORMS = "MatchAllWordForms"; private static final String MATCH_SOUNDS_LIKE = "MatchSoundsLike"; private static final String MATCH_WILDCARDS = "MatchWildcards"; private static final String MATCH_BYTE = "MatchByte"; private static final String MATCH_WHOLE_WORD = "MatchWholeWord"; private static final String MATCH_CASE = "MatchCase"; private static final String FORMAT = "Format"; private static final String FORWARD = "Forward"; private static final String EXECUTE = "Execute"; private static final String FALSE = "False"; private static final String TRUE = "True"; private static final String CLEAR_FORMATTING = "ClearFormatting"; private static final String SAVE_AS = "saveAs"; private static final String FIND = "Find"; private static final String HOME_KEY = "HomeKey"; private static final String TEXT = "Text"; private static final String SELECTION = "Selection"; private static final String DOCUMENTS = "Documents"; private static final String VISIBLE = "Visible"; private static final String OPEN = "Open"; private static final String QUIT = "Quit"; private static final String CLOSE = "Close"; private static final int wdFormatPDF = 17; private static final int wdDoNotSaveChanges = 0; protected static final Integer UNIT_WDSTORY = new Integer(6);// 移动光标至文档开始 protected static final Integer UNIT_WDLINE = new Integer(5);// 选择当前行 private static Logger log = LoggerFactory.getLogger(MSWordUtil.class); public static final String WORD_APP = "Word.Application"; protected IDispatch doc; protected Map<String, IDispatch> docs; protected IDispatch documents; protected String newFileName; protected static ReleaseManager rm; protected IDispatch word; static { log.info("加载jcom.dll"); URL url = MSWordUtil.class.getClassLoader().getResource("jcom.dll"); String filePath = url.getFile(); log.info("jcom.dll文件存放路径:" + filePath); System.load(filePath); rm = new ReleaseManager(); } public MSWordUtil() { try { word = new IDispatch(rm, WORD_APP); word.put(VISIBLE, new Boolean(true)); documents = (IDispatch) word.get(DOCUMENTS); docs = new HashMap<String, IDispatch>(); } catch (JComException e) { throw new RuntimeException("初始化word程序出错。服务器没有安装word程序"); } } public IDispatch open(String fileName) throws Exception { File file = new File(fileName); if (file.exists()) { doc = (IDispatch) documents.method(OPEN, new Object[] { fileName }); docs.put(fileName, doc); } else { throw new Exception("文件不存在:" + fileName); } return doc; } public void closeDoc(IDispatch doc, boolean saveOnExit) throws Exception { doc.method(CLOSE, new Object[] { new Boolean(saveOnExit) }); } public void closeAllDoc(boolean saveOnExit) throws Exception { for (IDispatch doc : docs.values()) { doc.method(CLOSE, new Object[] { new Boolean(saveOnExit) }); } } public void quit(int wdDoNotSaveChanges) throws Exception { word.method(QUIT, new Object[] { wdDoNotSaveChanges }); } public void quit() throws Exception { word.method(QUIT, new Object[] { wdDoNotSaveChanges }); } protected IDispatch getSelection() throws Exception { return (IDispatch) word.get(SELECTION); } protected boolean find(String findText) throws Exception { IDispatch find = (IDispatch) getSelection().get(FIND); find.method(CLEAR_FORMATTING, null); find.put(TEXT, findText); find.put(FORWARD, TRUE); find.put(FORMAT, FALSE); find.put(MATCH_CASE, TRUE); find.put(MATCH_WHOLE_WORD, FALSE); find.put(MATCH_BYTE, TRUE); find.put(MATCH_WILDCARDS, FALSE); find.put(MATCH_SOUNDS_LIKE, FALSE); find.put(MATCH_ALL_WORD_FORMS, FALSE); return new Boolean(find.method(EXECUTE, null).toString()); } public boolean replace(String findText, String newText) throws Exception { boolean leaf = false; if (find(findText)) { getSelection().put(TEXT, newText); getSelection().method(HOME_KEY, new Object[] { UNIT_WDSTORY }); leaf = true; } return leaf; } public boolean replaceAll(String findText, String replaceText) throws Exception { boolean leaf = false; while (find(findText)) { getSelection().put(TEXT, replaceText); getSelection().method(HOME_KEY, new Object[] { UNIT_WDSTORY }); leaf = true; } return leaf; } protected void replaceImage(IDispatch selection, String imagePath) throws Exception { IDispatch inlineShapes = (IDispatch) selection.get(INLINE_SHAPES); inlineShapes.method(ADD_PICTURE, new Object[] { imagePath }); } protected void replaceImage(IDispatch selection, String imagePath, int ZOrder, int width, int height) throws Exception { IDispatch inlineShapes = (IDispatch) selection.get(INLINE_SHAPES); IDispatch image = (IDispatch) inlineShapes.method(ADD_PICTURE, new Object[] { imagePath }); if (width == 0 && height == 0) { ImageIcon imageIcon = new ImageIcon(imagePath); width = imageIcon.getIconWidth(); height = imageIcon.getIconHeight(); } image.put(WIDTH, width); image.put(HEIGHT, height); IDispatch shape = null; try { Thread.sleep(500); shape = (IDispatch) image.method(CONVERT_TO_SHAPE, null); } catch (Exception e) { throw new Exception("插入图片出错"); } shape.method(Z_ORDER, new Object[] { ZOrder }); Float left = Float.parseFloat(shape.get(LEFT).toString()); Float top = Float.parseFloat(shape.get(TOP).toString()); shape.method("IncrementTop", new Object[] { -height / 2 }); log.info("left=" + left + ":top=" + top); } public boolean replaceImage(String toFindText, String imagePath) throws Exception { boolean leaf = false; if (find(toFindText)) { replaceImage(getSelection(), imagePath); getSelection().method(HOME_KEY, new Object[] { UNIT_WDSTORY }); leaf = true; } return leaf; } /** * 查找toFindText,替换成指定的图片 * * @param toFindText * - String 欲替换的文本 * @param imagePath * - String 图片文件全路径 * @param ZOrder * - String 图片版式 4浮于文字上方,5浮于文字下方 * @return * @throws Exception */ public boolean replaceImage(String toFindText, String imagePath, int ZOrder, int width, int height) throws Exception { boolean leaf = false; if (find(toFindText)) { replaceImage(getSelection(), imagePath, ZOrder, width, height); getSelection().method(HOME_KEY, new Object[] { UNIT_WDSTORY }); leaf = true; } return leaf; } /** * 查找toFindText,替换成指定的图片 * * @param toFindText * - String 欲替换的文本 * @param imagePath * - String 图片文件全路径 * @param ZOrder * - String 图片版式 4浮于文字上方,5浮于文字下方 * @return * @throws Exception */ public boolean replaceAllImage(String toFindText, String imagePath, int ZOrder, int width, int height) throws Exception { boolean leaf = false; while (find(toFindText)) { replaceImage(getSelection(), imagePath, ZOrder, width, height); getSelection().method("HomeKey", new Object[] { new Integer(6) }); leaf = true; } return leaf; } /** * 查找toFindText,并替换为指定的word文件内容 * * @param toFindText * - String 欲替换的文本 * @param docFile * - String doc文件的全路径 * @throws Exception */ public boolean replaceFile(String toFindText, String docFile) throws Exception { boolean leaf = false; if (find(toFindText)) { replaceFile(getSelection(), docFile); getSelection().method("HomeKey", new Object[] { new Integer(6) }); leaf = true; } return leaf; } protected void replaceFile(IDispatch selection, String docFile) throws Exception { selection.method("insertFile", new Object[] { docFile, "", new Boolean(false), new Boolean(false), new Boolean(false) }); selection.method("TypeBackspace", null); } /** * 查找toFindText,并替换为指定的word文件内容 * * @param toFindText * - String 欲替换的文本 * @param docFile * - String doc文件的全路径 * @throws Exception */ public boolean replaceAllFile(String toFindText, String docFile) throws Exception { boolean leaf = false; while (find(toFindText)) { replaceFile(getSelection(), docFile); getSelection().method("HomeKey", new Object[] { new Integer(6) }); leaf = true; } return leaf; } protected void insertTable(IDispatch range, List<Object[]> dataList) throws Exception { IDispatch table; if (dataList.size() < 1) { System.out.println("Empty table!"); return; } Object titleData[] = dataList.get(0); int rowLength = dataList.size(); int colLength = titleData.length; IDispatch tables = (IDispatch) doc.get(TABLES); table = (IDispatch) tables.method("Add", new Object[] { range, rowLength, colLength }); for (int i = 1; i <= rowLength; i++) { Object datas[] = dataList.get(i - 1); for (int j = 1; j <= datas.length; j++) { IDispatch cell = (IDispatch) table.method(CELL, new Object[] { new Integer(i), new Integer(j) }); IDispatch cellRange = (IDispatch) cell.get(RANGE); cellRange.put("Text", datas[j - 1]); } } } /** * 在指定行后面添加count行 * * @param tbIndex * 指定表格 * @param rowIndex * 第几行 * @param count * 添加几行 * @return * @throws Exception */ public boolean insertTabRow(int tbIndex, int rowIndex, int colIndex, int count) throws Exception { IDispatch cell = getTabCell(tbIndex, rowIndex, colIndex); IDispatch range = (IDispatch) cell.get(RANGE); range.method("select", null); getSelection().method("InsertRowsBelow", new Object[] { count }); return true; } public boolean insertTabRow(int tbIndex) throws Exception { IDispatch rows = getRows(tbIndex); rows.method("Add", null); return true; } /** * 填充表格数据 如果输入的数据宽度(列数)超出模板设置,则超出的部分不会被插入 * * @throws Exception */ public void replaceTable(int tbIndex, int fromRow, int fromCol, List<Object[]> dataList) throws Exception { if (dataList.size() < 1) { System.out.println("Empty table!"); return; } IDispatch rows = getRows(tbIndex); int rowsCount = getTabRowCount(tbIndex); int columnsCount = getTabColCount(tbIndex); if (fromRow > rowsCount) { for (int i = 0; i < fromRow - rowsCount; i++) { rows.method("Add", null); } } else if (fromRow == -1) { fromRow = rowsCount; } int rowSum = 0; for (int i = fromRow, index = 0; index < dataList.size(); i++, index++) { Object datas[] = dataList.get(index); List<List<?>> rowChildList = new ArrayList<List<?>>(); List<Integer[]> list = new ArrayList<Integer[]>(); for (int j = fromCol, h = 0; h < datas.length && j <= columnsCount; j++, h++) { Object item = datas[h]; int rowChildColSum = 0; for (Object object : rowChildList) { Object[] array = ((Object[]) ((List<?>) object).get(0)); if (array.length > 1) { rowChildColSum += array.length - 1; } else { rowChildColSum += 1; } } if (item instanceof java.lang.String) { setCellText(tbIndex, i + rowSum, (rowChildColSum > 0 ? j + rowChildColSum : j), datas[h] == null ? "" : datas[h].toString()); } else if (item instanceof java.util.List<?>) { List<?> childDataList = (List<?>) item; if (childDataList.size() == 0) continue; int numRows = childDataList.size(); int numColumns = 0; int lastRowMergeNum = 0; for (Object object : childDataList) { Object[] dataA = (Object[]) object; if (dataA.length > numColumns) { numColumns = dataA.length; } lastRowMergeNum = dataA.length; } splitCell(tbIndex, i + rowSum, (rowChildColSum > 0 ? j + rowChildColSum : j), numRows, numColumns); list.add(new Integer[] { j, lastRowMergeNum }); for (int k = 0; k < childDataList.size(); k++) { Object[] dataA = (Object[]) childDataList.get(k); if (dataA.length < numColumns) { rowChildColSum = 0; for (Object object : rowChildList) { rowChildColSum += ((Object[]) ((List<?>) object) .get(k)).length - 1; } int form_Col = rowChildColSum > 0 ? j + rowChildColSum : j; mergeCell(tbIndex, i + rowSum + k, form_Col, i + rowSum + k, form_Col + numColumns - dataA.length); } } for (int k = 0; k < childDataList.size(); k++) { Object[] dataA = (Object[]) childDataList.get(k); rowChildColSum = 0; for (Object object : rowChildList) { rowChildColSum += ((Object[]) ((List<?>) object) .get(k)).length - 1; } for (int l = 0; l < dataA.length; l++) { setCellText(tbIndex, i + rowSum + k, l + (rowChildColSum > 0 ? j + rowChildColSum : j), dataA[l].toString()); } } rowChildList.add(childDataList); } else { throw new Exception("传入的集合格式不正确!"); } } int maxRowSum = 0; for (Object item : datas) { if (item instanceof java.util.List<?>) { if (maxRowSum < ((List<?>) item).size()) { maxRowSum = ((List<?>) item).size(); } } } rowSum += (maxRowSum > 1 ? maxRowSum - 1 : 0); if (index + 1 != dataList.size()) { rows.method("Add", null); for (Integer[] array : list) { mergeCell(tbIndex, i + rowSum + 1, array[0], i + rowSum + 1, array[0] + array[1] - 1); } } } } /** * 拆分指定单元格为指定的几行几列 * * @param tbIndex * @param fromRow * @param fromCol * @param numRows * @param numColumns * @throws Exception */ public void splitCell(int tbIndex, int fromRow, int fromCol, int numRows, int numColumns) throws Exception { IDispatch cell = getTabCell(tbIndex, fromRow, fromCol); cell.method("split", new Object[] { numRows, numColumns }); } /** * 合并单元格 * * @param tbIndex * @param fromRow * @param fromCol * @param toRow * @param toCol * @throws Exception */ public void mergeCell(int tbIndex, int fromRow, int fromCol, int toRow, int toCol) throws Exception { int rowsCount = getTabRowCount(tbIndex); if (fromRow < 1 || fromRow > rowsCount) fromRow = 1; if (toRow < 1 || toRow > rowsCount) toRow = rowsCount; int Columnscount = getTabColCount(tbIndex); if (fromCol < 1 || fromCol > Columnscount) fromCol = 1; if (toCol < 1 || toCol > Columnscount) toCol = Columnscount; IDispatch fromCell = getTabCell(tbIndex, fromRow, fromCol); IDispatch toCell = getTabCell(tbIndex, toRow, toCol); fromCell.method("Merge", new Object[] { toCell }); } /** * 填充指定单元格文本内容 * * @param tbIndex * @param row * @param col * @param text * @throws Exception */ public void setCellText(int tbIndex, int row, int col, String text) throws Exception { IDispatch cell = null; try { cell = getTabCell(tbIndex, row, col); } catch (Exception e) { throw new Exception("获取单元格:" + row + "行" + col + "列失败"); } IDispatch cellRange = (IDispatch) cell.get(RANGE); cellRange.put("Text", text); } protected IDispatch getRows(int tbIndex) throws Exception { IDispatch table = getTable(tbIndex); return (IDispatch) table.get(ROWS); } protected IDispatch getCloumn(int tbIndex) throws Exception { IDispatch table = getTable(tbIndex); return (IDispatch) table.get(COLUMNS); } /** * 获取指定表格有多少列 * * @param tbIndex * - int 表格索引 * @return 返回该表格由多少列组成 * @throws Exception */ public int getTabColCount(int tbIndex) throws Exception { IDispatch Columns = (IDispatch) getTable(tbIndex).get(COLUMNS); return (Integer) Columns.get(COUNT); } /** * 获取指定表格的指定行的列数 * * @param tbIndex * @param rowIndex * @return * @throws Exception */ public int getTabRowColCount(int tbIndex, int rowIndex) throws Exception { IDispatch row = getTabRow(tbIndex, rowIndex); // row.method("Select", null); IDispatch cells = (IDispatch) row.get(CELLS); return (Integer) cells.get(COUNT); } /** * 获取指定表格有多少行 * * @param tbIndex * - int 表格索引 * @return 返回该表格由多少行组成 * @throws Exception */ public int getTabRowCount(int tbIndex) throws Exception { IDispatch rows = (IDispatch) getTable(tbIndex).get(ROWS); return (Integer) rows.get(COUNT); } /** * 获取指定索引的表格对象 * * @param tbIndex * @return * @throws Exception */ protected IDispatch getTable(int tbIndex) throws Exception { IDispatch tables = (IDispatch) doc.get(TABLES); try { return (IDispatch) tables.method(ITEM, new Object[] { tbIndex }); } catch (Exception e) { throw new Exception("索引为:" + tbIndex + "的表格不存在!"); } } protected IDispatch getTabRow(int tbIndex, int rowIndex) throws Exception { IDispatch rows = getRows(tbIndex); IDispatch row = (IDispatch) rows .method(ITEM, new Object[] { rowIndex }); return row; } /** * 删除指定表格的指定行 * * @param tbIndex * - int 表格索引 * @param rowIndex * - int 表格行索引 * @throws Exception */ public void delTabRow(int tbIndex, int rowIndex) throws Exception { IDispatch row = getTabRow(tbIndex, rowIndex); row.method("Select", null); row.method("Delete", null); } protected IDispatch getTabCell(int tbIndex, int row, int col) throws Exception { return (IDispatch) getTable(tbIndex).method(CELL, new Object[] { new Integer(row), new Integer(col) }); } /** * 判断指定行是否是空行,就是该行的每个单元格内容为空 * * @param tbIndex * @param rowIndex * @return * @throws Exception */ public boolean rowIsEmpty(int tbIndex, int rowIndex) throws Exception { int cols = getTabColCount(tbIndex); for (int i = 1; i <= cols; i++) { IDispatch cell = getTabCell(tbIndex, rowIndex, i); IDispatch cellRange = (IDispatch) cell.get(RANGE); String cellText = cellRange.get(TEXT).toString(); if (!"\r".equals(cellText)) { return false; } } return true; } /** * 获取word中指定表格的数据,以java集合形式返回 * * @param i * @return * @throws Exception */ public List<String[]> tableToList(int tbIndex) throws Exception { List<String[]> dataList = new ArrayList<String[]>(); int rows = getTabRowCount(tbIndex); int cols = getTabColCount(tbIndex); for (int i = 1; i <= rows; i++) { String[] rowItem = new String[cols]; for (int j = 1; j <= cols; j++) { IDispatch cell = getTabCell(tbIndex, i, j); IDispatch range = (IDispatch) cell.get(RANGE); rowItem[j - 1] = range.get(TEXT).toString(); } dataList.add(rowItem); } return dataList; } public boolean savePDF(String inputFile, String outputFile) throws Exception { IDispatch doc = open(inputFile); doc.method(SAVE_AS, new Object[] { outputFile, wdFormatPDF }); return true; } public boolean savePDF(String outputFile) throws Exception { doc.method(SAVE_AS, new Object[] { outputFile, wdFormatPDF }); return true; } public void saveDoc(String outputFile) throws Exception { doc.method(SAVE_AS, new Object[] { outputFile, new Integer(0) }); } protected void moveDown(IDispatch selection, int count) throws Exception { for (int i = 0; i < count; i++) { selection.method("MoveDown", null); } } protected void moveDown(int count) throws Exception { moveDown(getSelection(), count); } protected void moveLeft(IDispatch selection, int count) throws Exception { for (int i = 0; i < count; i++) { selection.method("MoveLeft", null); } } protected void moveLeft(int count) throws Exception { moveLeft(getSelection(), count); } protected void moveRight(IDispatch selection, int count) throws Exception { for (int i = 0; i < count; i++) { selection.method("MoveRight", null); } } protected void moveStart(IDispatch selection) throws Exception { selection.method("HomeKey", new Object[] { 6 }); } protected void moveUp(IDispatch selection, int count) throws Exception { for (int i = 0; i < count; i++) { selection.method("MoveUp", null); } } protected void moveUp(int count) throws Exception { moveUp(getSelection(), count); } }
- org.forever.office_20110704_.rar (273.8 KB)
- 下载次数: 16
发表评论
-
OSGI学习
2012-03-18 18:01 0http://www.blogjava.net/zhenyu3 ... -
OSGI学习笔记(七)
2012-03-17 23:58 1702SpringDM初步使用(二) 介绍哈官方的第二个例子 ... -
ubuntu10.04下nexus和maven的安装及配置
2012-03-14 16:14 2514前提要有jdk环境,官方下载nexus和maven,解压后创建 ... -
ubuntu10.04下eclipse的安装及配置
2012-03-14 00:01 1310从官方http://www.eclipse.org/downl ... -
Ubuntu10.04下配置java环境变量
2012-03-13 23:28 1069Ubuntu10.04默认安装了OpenJDK,但还是基于Su ... -
eclipse设置保护色
2012-03-16 09:22 9418eclipse操作界面默认颜色为白色。对于我们长期使 ... -
OSGI学习笔记(六)
2012-03-17 15:08 2757SpringDM初步使用(一) 官方地址http:// ... -
OSGI学习笔记(八)
2012-03-19 21:08 2308SpringDM初步使用(三) spring第三个例子 ... -
OSGI学习笔记(五)
2011-07-31 10:32 1588开放服务网关协议 (Open Services Gateway ... -
osgi学习笔记(三)
2011-07-16 22:43 1963OSGI实战书上讲了一个web登陆验证切换功能。表达了osgi ... -
命令模式--撤销恢复
2011-03-14 22:32 4989该例子来自阎宏提供的 ... -
java zip
2011-03-06 15:32 1219import java.io.BufferedInputStr ... -
doc转swf
2010-12-07 22:03 8550将doc转换成swf,然后显示在html页面上。 packa ... -
javamail简单使用
2010-11-15 08:29 2355MailInfo类: //发送邮件的信息类 public ... -
xloadtree的一个改造
2010-09-20 22:58 2574修改了xloadtree的部分源码以适合自己使用。 1.修改 ... -
java与Delphi写的dll交互
2010-09-05 22:27 6171有时候在项目开发的时候难免会和硬件提供的开发包接触,这些开发接 ... -
JAVA与DLL交互
2010-08-27 23:32 1949jna官网地址:https://jna.dev.java.ne ... -
office工具类
2010-07-31 14:17 2313将jcom.dll放入jdk的bin目录下,将jcom.jar ... -
启动多个tomcat
2010-04-22 09:13 1222想启动多个tomcat,只需修改conf/server.xml ... -
dos 删除指定日期前的文件
2010-04-19 22:47 3466@echo off&setlocal enablede ...
相关推荐
这个“JAVA生成WORD工具类”提供了一种解决方案,使得开发者可以通过代码动态地生成Word文档,避免手动操作的繁琐和错误。下面将详细介绍这个工具类的工作原理和可能的应用场景。 首先,Java生成Word文档通常涉及到...
poi写word工具类,包括添加标题,插入表格,合并单元格,插入图片,自动生成目录;代码见 https://blog.csdn.net/zheng_chang_wei/article/details/89448055
操作Word文档工具类,丰富的方法, 无论你是想要创建文档还是操作模板;无论你是想要添加图片,还是想要添加文字;无论你想要添加书签,还是操作书签;无论你是想要修改表格,还是添加表格;它都是你的选择
按模板导出Word工具类
XWPF(XML Word Processing)提供了创建和操作Word文档所需的类和接口。在Java代码中,我们通常会用到`XWPFDocument`、`XWPFParagraph`、`XWPFRun`、`XWPFTable`和`XWPFTableCell`等类。 1. **导出07版Word(docx)**...
标题中的“工具类级”意味着我们需要创建一个Java类,这个类将封装Jacob库的使用,提供简洁易用的API供其他Java代码调用。这样做的好处是提高了代码的可维护性和可重用性,避免了直接在业务逻辑中嵌入复杂的COM交互...
完整的支持POI操作word以下功能: 1.替换模板数据 2,替换表格数据 3.word表格行内添加 4.word写入写出
本文提供关于jacob配置的dll文件,java2word的运行安装文件,jacob和java2word整合jar包 ckedtior网页编辑器需要用的jar,以及使用整合后的jar对word进行插入图片、带格式文字段落、和导出word功能源码
【createWord】是一个基于Java开发的工具类项目,主要用于利用FreeMarker模板技术生成Word文档。在实际的IT工作中,这样的工具对于批量生成报告、合同或者其他需要格式化文本的场景非常有用。下面将详细介绍这个项目...
在工作中经常需要用到PDF文档,因此需要一款好的PDF工具,现在又各种的PDF工具,可能最熟悉、最知名的就是adobe acrobat这款PDF工具,功能强大也非常专业,但是因为专业,包含各种功能,所以体积上也非常庞大,小编...
标题"word转pdf jarbao及工具类"暗示我们将探讨如何使用特定的Java库(jar包)以及工具类来完成这个转换。 首先,我们要了解的是Java中的库Sapose。Sapose是一系列强大的API,用于处理各种文件格式,包括Microsoft ...
总的来说,PDF转Word工具是办公环境中不可或缺的辅助软件,尤其适合需要频繁进行格式转换的用户。这款"超级工具"凭借其高效的转换能力和高度的格式保留,无疑为用户提供了极大的便利。在使用过程中,正确使用和管理...
easypoi功能如同名字easy,主打的功能就是容易,让一个没见...POI 工具类,Excel的快速导入导出,Excel模板导出,Word模板导出,可以仅仅5行代码就可以完成Excel的导入导出,修改导出格式简单粗暴,快速有效,easypoi值得你尝试
使用poi将word读取后替换指定内容后再次生成新word,本人经过测试,拿来即用!
使用HWPF库,可以通过`Document`类创建一个新的Word文档: ```java Document document = new Document(); document.createParagraph().createRun().setText("Hello, World!"); document.write(new ...
java将.docx文件和.doc文件转为html文件的工具类。。。