使用docx4j生成数据库字典文档
使用docx4j生成数据库字典文档
文本参考文章
https://www.cnblogs.com/qlqwjy/p/9866484.html
https://my.oschina.net/haiyangyiba/blog/2246089
https://github.com/plutext/docx4j/
1.引入docx4j
本案例使用maven仓库引入jar包
<dependency><groupId>org.docx4j</groupId><artifactId>docx4j</artifactId><version>6.1.2</version>
</dependency><!-- lombok -->
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.18</version>
</dependency><!-- JSON插件 -->
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.47</version>
</dependency>
2.docx4j配置
可以不添加配置文件,但debug日志会提示找不到docx4j配置文件
在src下创建docx4j.properties配置文件,maven项目请放在resources文件夹下
# Page size: use a value from org.docx4j.model.structure.PageSizePaper enum
# eg A4, LETTER
docx4j.PageSize=LETTER
# Page size: use a value from org.docx4j.model.structure.MarginsWellKnown enum
docx4j.PageMargins=NORMAL
docx4j.PageOrientationLandscape=false
# Page size: use a value from org.pptx4j.model.SlideSizesWellKnown enum
# eg A4, LETTER
pptx4j.PageSize=LETTER
pptx4j.PageOrientationLandscape=false
# These will be injected into docProps/app.xml
# if App.Write=true
docx4j.App.write=true
docx4j.Application=docx4j
docx4j.AppVersion=6.1.2
# of the form XX.YYYY where X and Y represent numerical values
# These will be injected into docProps/core.xml
docx4j.dc.write=true
docx4j.dc.creator.value=docx4j
docx4j.dc.lastModifiedBy.value=docx4j
#
#docx4j.McPreprocessor=true
# If you haven't configured log4j yourself
# docx4j will autoconfigure it. Set this to true to disable that
docx4j.Log4j.Configurator.disabled=false
3.生成数据字典.docx
public static void main(String[] args) throws Exception{String templateFilePath = "template.docx";String wordFilePath = "数据字典.docx";HashMap<String, String> params = new HashMap<>();params.put("system_name", "xxx系統");params.put("title", "數據字典");params.put("author", "test");params.put("date", "2021-03-21");// 数据字典DataDict dataDict = mockData();// 创建wordWordprocessingMLPackage wordMLPackage = Docx4jUtils.load(templateFilePath);// 写入数据清单writeTableDict(wordMLPackage, dataDict);// 写入数据明细writeTableDetail(wordMLPackage, dataDict);// 参数替换Docx4jUtils.variableReplace(wordMLPackage, params);// 写入目录writeToc(wordMLPackage);// saveDocx4jUtils.save(wordMLPackage, wordFilePath);}/*** 写入数据清单*/private static void writeTableDict(WordprocessingMLPackage wordMLPackage, DataDict dataDict) throws Exception{// 查找tableClassFinder find = new ClassFinder(Tbl.class);new TraversalUtil(wordMLPackage.getMainDocumentPart().getContent(), find);//获取到第三个表格元素=数据清单Tbl table = (Tbl) find.results.get(2);// 第二行约定为模板,获取到第二行内容Tr dynamicTr = (Tr) table.getContent().get(1);// 获取模板行的xml数据String dynamicTrXml = XmlUtils.marshaltoString(dynamicTr);// 替换数据LinkedHashMap<String, String> map;for(UserTable userTable : dataDict.getUserTables()){map = new LinkedHashMap<>();map.put("table_name", userTable.getTableName());map.put("table_comment", userTable.getComments());// 填充模板行数据Tr newTr = (Tr) XmlUtils.unmarshallFromTemplate(dynamicTrXml, map);table.getContent().add(newTr);}// 删除模板行的占位行table.getContent().remove(1);}/*** 写入数据表明细*/private final static String TITLE = "2.%s %s %s";private static void writeTableDetail(WordprocessingMLPackage wordMLPackage, DataDict dataDict){// 提取正文MainDocumentPart main = wordMLPackage.getMainDocumentPart();ObjectFactory factory = Context.getWmlObjectFactory();// 数据表List<UserTable> userTables = dataDict.getUserTables();List<String> primaryKeys = new ArrayList<>();for(int i=0; i<userTables.size(); i++){UserTable userTable = userTables.get(i);// 设置标题// styleId=3为标题2main.addStyledParagraphOfText("3", String.format(TITLE, (i+1), userTable.getTableName(), userTable.getComments()));// 创建表格Tbl table = factory.createTbl();// 必须设置一个TblPr,否则最后会报空指针异常table.setTblPr(new TblPr());// 设置表格边框样式// 设置表格边框样式TableBorderStyle borderStyle = new TableBorderStyle();borderStyle.setColor("auto");borderStyle.setSize(new BigInteger("4"));borderStyle.setSpace(new BigInteger("0"));borderStyle.setStyle(STBorder.SINGLE);CTBorder ctBorder = Docx4jUtils.buildTableBorder(borderStyle);TblBorders tblBorders = Docx4jUtils.setTableBorder(ctBorder,ctBorder,ctBorder,ctBorder);table.getTblPr().setTblBorders(tblBorders);table.getTblPr().setTblW(Docx4jUtils.buildTblWidth(BigInteger.valueOf(5000)));// 写入标题addTableTitle(factory, table);// 字段信息List<UserTabColumn> userTabColumns = dataDict.getUserTabColumns().get(userTable.getTableName());for(UserTabColumn userTabColumn : userTabColumns){// 创建行Tr tr = factory.createTr();String columnName = userTabColumn.getColumnName();List<UserColComment> userColComments = dataDict.getUserColComment().get(userTable.getTableName() + columnName);String columnComment = userColComments.get(0).getComments();String dataType = userTabColumn.getDataType();switch (dataType){case "NCLOB":dataType = "CLOB";break;case "NBLOB":dataType = "BLOB";break;case "NVARCHAR2":dataType = "VARCHAR2";break;}if (!("CLOB".equals(dataType) || "BLOB".equals(dataType) || "NUMBER".equals(dataType))) {dataType = String.format("%s(%s)", dataType, userTabColumn.getDataLength());} else if ("NUMBER".equals(dataType)) {dataType = String.format("%s(%s,%s)",dataType,userTabColumn.getDataPrecision(),userTabColumn.getDataScale());}String notNull = "TRUE";if ("NO".equals(userTabColumn.getDefaultOnNull())) {notNull = "FALSE";}tr.getContent().add(buildTableRow(factory, columnName,1000));tr.getContent().add(buildTableRow(factory, dataType,1000));tr.getContent().add(buildTableRow(factory, notNull,1000));tr.getContent().add(buildTableRow(factory, columnComment,2000));table.getContent().add(tr);}// 索引信息List<String> idxData = new ArrayList<>();// 主键索引信息primaryKeys.clear();List<UserConstraint> userConstraints = dataDict.getUserConstraints().get(userTable.getTableName());if(null != userConstraints && userConstraints.size() > 0){for(UserConstraint userConstraint : userConstraints){primaryKeys.add(userConstraint.getIndexName());List<UserIndColumn> userIndColumns = dataDict.getUserIndColumns().get(userConstraint.getTableName() + userConstraint.getIndexName());StringBuilder pkCols = new StringBuilder();for(UserIndColumn userIndColumn : userIndColumns){pkCols.append("\"").append(userIndColumn.getColumnName()).append("\",");}idxData.add("主键: " + userConstraint.getIndexName() + "(" + pkCols.substring(0, pkCols.length()-1) + ")");}}// 非主键索引List<UserIndex> userIndices = dataDict.getUserIndexes().get(userTable.getTableName());if(null != userIndices && userIndices.size() > 0){for(UserIndex userIndex : userIndices){if (primaryKeys.contains(userIndex.getIndexName())) {continue;}List<UserIndColumn> userIndColumns = dataDict.getUserIndColumns().get(userIndex.getTableName() + userIndex.getIndexName());if(null == userIndColumns || userIndColumns.size() == 0){continue;}StringBuilder stb = new StringBuilder();boolean flag = false;for (UserIndColumn userIndColumn : userIndColumns) {if (userIndex.getIndexName().equals(userIndColumn.getIndexName())) {stb.append("\"").append(userIndColumn.getColumnName()).append("\",");flag = true;}}if (flag) {String uniqueness = "NONUNIQUE".equals(userIndex.getUniqueness()) ? "索引" : "唯一索引";idxData.add(String.format("%s: %s(%s)", uniqueness, userIndex.getIndexName(), stb.substring(0, stb.length() -1)));}}}// 新增索引信息addTableIndex(factory, table, idxData, BigInteger.valueOf(5000));// 加表格加到主要内容中main.addObject(table);}}/*** 新增表格标题*/private static void addTableTitle(ObjectFactory factory, Tbl table){Tr tr = factory.createTr();tr.getContent().add(buildTableTitle(factory, "字段名稱", 1000));tr.getContent().add(buildTableTitle(factory, "字段類型", 1000));tr.getContent().add(buildTableTitle(factory, "是否強制", 1000));tr.getContent().add(buildTableTitle(factory, "字段描述", 2000));table.getContent().add(tr);}/*** 构建表格标题*/private static Tc buildTableTitle(ObjectFactory factory, String title, int width){Tc tc = factory.createTc();P p = factory.createP();R r = factory.createR();// 设置表格标题字体样式FontStyle tableTitleStyle = new FontStyle();tableTitleStyle.setSize(BigInteger.valueOf(24));tableTitleStyle.setBold(true);RPr rPr = Docx4jUtils.buildFontStyle(factory, tableTitleStyle);r.setRPr(rPr);// 内容Text text = factory.createText();text.setValue(title);TcPr tcPr = Docx4jUtils.getTcPr(tc);// 设置宽度tcPr.setTcW(Docx4jUtils.buildTblWidth(BigInteger.valueOf(width)));// 设置背景颜色CTShd shd = new CTShd();shd.setVal(STShd.CLEAR);shd.setColor("auto");shd.setFill("eeeeee");tcPr.setShd(shd);r.getContent().add(text);p.getContent().add(r);tc.getContent().add(p);return tc;}/*** 构建行信息*/private static Tc buildTableRow(ObjectFactory factory, String content, int width){Tc tc = factory.createTc();P p = factory.createP();R r = factory.createR();// 设置字体样式FontStyle tableContentStyle = new FontStyle();tableContentStyle.setSize(BigInteger.valueOf(22));RPr rPr = Docx4jUtils.buildFontStyle(factory, tableContentStyle);r.setRPr(rPr);// 内容Text text = factory.createText();text.setValue(content);// 设置宽度Docx4jUtils.getTcPr(tc).setTcW(Docx4jUtils.buildTblWidth(BigInteger.valueOf(width)));r.getContent().add(text);p.getContent().add(r);tc.getContent().add(p);return tc;}/*** 新增索引信息*/private static void addTableIndex(ObjectFactory factory, Tbl table, List<String> data, BigInteger width){Tr tr = factory.createTr();Tc tc = factory.createTc();// 设置宽度Docx4jUtils.getTcPr(tc).setTcW(Docx4jUtils.buildTblWidth(width));for(String item : data){P p = factory.createP();R r = factory.createR();// 设置字体样式FontStyle tableContentStyle = new FontStyle();tableContentStyle.setSize(BigInteger.valueOf(22));RPr rPr = Docx4jUtils.buildFontStyle(factory, tableContentStyle);r.setRPr(rPr);// 内容Text text = factory.createText();text.setValue(item);r.getContent().add(text);p.getContent().add(r);tc.getContent().add(p);}tr.getContent().add(tc);table.getContent().add(tr);}/*** 写入目录*/private static void writeToc(WordprocessingMLPackage wordMLPackage) throws Exception{// 提取正文MainDocumentPart main = wordMLPackage.getMainDocumentPart();List<Object> list = main.getContent();for(int i=0; i<list.size(); i++){Object item = list.get(i);if("目錄".equals(item.toString())){Docx4jUtils.tocGenerator(wordMLPackage, i, "目錄");P p = (P)item;p.getContent().removeAll(p.getContent());break;}}}
4.模板信息截图
5.生成数据字典截图
6.docx4j相关API
docx格式文档可以理解为一个压缩包,若将其解压可看到一个类似前端的工程项目,其中document.xml用于全文的配置,详细解说请自行查阅资料
创建新的word文档
/*** 创建新的word文件*/public static WordprocessingMLPackage build() throws InvalidFormatException {return WordprocessingMLPackage.createPackage();}
读取存在的word文件
/*** 读取存在的word文件* @param wordFilePath word文件路径*/public static WordprocessingMLPackage load(String wordFilePath) throws Docx4JException{return WordprocessingMLPackage.load(new File(wordFilePath));}
保存word文件
/*** 保存word文件* @param wordMLPackage word*/public static void save(WordprocessingMLPackage wordMLPackage,String wordFilePath) throws Docx4JException {wordMLPackage.save(new File(wordFilePath));}
构建字体样式
/*** 构建字体样式* @return RPr*/public static RPr buildFontStyle(ObjectFactory factory, FontStyle style){RPr rpr = factory.createRPr();//设置字体if(StringUtils.isNotBlank(style.getCnFontFamily()) || StringUtils.isNotBlank(style.getEnFontFamily())){RFonts font = new RFonts();font.setAscii(StringUtils.isBlank(style.getCnFontFamily()) ? "宋体" : style.getCnFontFamily());if(StringUtils.isNotBlank(style.getEnFontFamily())){font.setEastAsia(style.getEnFontFamily());}rpr.setRFonts(font);}//设置颜色if(StringUtils.isNotBlank(style.getColor())){Color color = new Color();color.setVal(style.getColor());rpr.setColor(color);}//设置字体大小if(null != style.getSize()){HpsMeasure fontSize = new HpsMeasure();fontSize.setVal(style.getSize());rpr.setSzCs(fontSize);rpr.setSz(fontSize);}//设置粗体if(null != style.getBold()){BooleanDefaultTrue bold = factory.createBooleanDefaultTrue();bold.setVal(style.getBold());rpr.setB(bold);}//设置斜体if(null != style.getItalic()){BooleanDefaultTrue italic = new BooleanDefaultTrue();rpr.setI(italic);}//设置删除线if(null != style.getDeleteLine()){BooleanDefaultTrue deleteLine = new BooleanDefaultTrue();deleteLine.setVal(style.getDeleteLine());rpr.setStrike(deleteLine);}//设置下划线if(null != style.getUnderlineEnumeration()){U u = factory.createU();u.setVal(style.getUnderlineEnumeration());rpr.setU(u);}// 设置背景颜色if (null != style.getBackgroundColor()) {CTShd shd = new CTShd();shd.setVal(style.getBackgroundColor());rpr.setShd(shd);}// 设置边框样式if(StringUtils.isNotBlank(style.getBorderColor()) || null != style.getBorderSize() || null != style.getBorderSpace()){CTBorder border = new CTBorder();if(StringUtils.isNotBlank(style.getBorderColor())){border.setColor(style.getBorderColor());}if(null != style.getBorderSize()){border.setSz(style.getBorderSize());}if(null != style.getBorderSpace()){border.setSpace(style.getBorderSpace());}if(null != style.getBorderShadow()){border.setShadow(style.getBorderShadow());}}// 着重号if(null != style.getEmphasis()){CTEm em = new CTEm();em.setVal(style.getEmphasis());rpr.setEm(em);}// 空心if(null != style.getOutline()){BooleanDefaultTrue outline = new BooleanDefaultTrue();outline.setVal(style.getOutline());rpr.setOutline(outline);}// 设置上标下标if(null != style.getVerticalAlign()){CTVerticalAlignRun value = new CTVerticalAlignRun();value.setVal(style.getVerticalAlign());rpr.setVertAlign(value);}// 设置字符间距缩进if(null != style.getIndent()){CTTextScale value = new CTTextScale();value.setVal(style.getIndent());rpr.setW(value);}// 设置字符间距信息if(null != style.getSpacing()){CTSignedTwipsMeasure value = new CTSignedTwipsMeasure();value.setVal(style.getSpacing());rpr.setSpacing(value);}// 设置文本位置if(null != style.getPosition()){CTSignedHpsMeasure ctPosition = new CTSignedHpsMeasure();ctPosition.setVal(style.getPosition());rpr.setPosition(ctPosition);}// 阴文if(null != style.getImprint()){BooleanDefaultTrue imprint = new BooleanDefaultTrue();imprint.setVal(style.getImprint());rpr.setImprint(imprint);}// 阳文if(null != style.getEmboss()){BooleanDefaultTrue emboss = new BooleanDefaultTrue();emboss.setVal(style.getEmboss());rpr.setEmboss(emboss);}// 设置隐藏if(null != style.getVanish()){BooleanDefaultTrue vanish = new BooleanDefaultTrue();vanish.setVal(style.getVanish());rpr.setVanish(vanish);}// 设置阴影if(null != style.getShadow()){BooleanDefaultTrue shadow = new BooleanDefaultTrue();shadow.setVal(style.getShadow());rpr.setShadow(shadow);}// 设置底纹if(null != style.getShading()){CTShd shd = new CTShd();shd.setVal(style.getShading());rpr.setShd(shd);}// 设置突出显示文本if(null != style.getHightlight()){Highlight highlight = new Highlight();highlight.setVal(style.getHightlight());rpr.setHighlight(highlight);}// 设置删除线if(null != style.getStrike()){BooleanDefaultTrue strike = new BooleanDefaultTrue();strike.setVal(style.getStrike());rpr.setStrike(strike);}// 设置双删除线if(null != style.getDoubleStrike()){BooleanDefaultTrue strike = new BooleanDefaultTrue();strike.setVal(style.getDoubleStrike());rpr.setDstrike(strike);}// 倾斜if(null != style.getTilt()){BooleanDefaultTrue b = new BooleanDefaultTrue();b.setVal(style.getTilt());rpr.setI(b);}return rpr;}
设置表格宽度
/*** 设置表格宽度* @param val 宽度 5000为百分之百的宽度* @return TblWidth*/public static TblWidth buildTblWidth(BigInteger val){TblWidth width = new TblWidth();width.setW(val);//此处试了几种方式均不好用,只有这个pct的合适,50分之一是一个百分点,5000为百分之百的宽度width.setType("pct");return width;}
模板参数替换
/*** 模板参数替换* 格式 ${param1}*/public static void variableReplace(MainDocumentPart main, HashMap<String, String> params) throws JAXBException, Docx4JException{main.variableReplace(params);}/*** 模板参数替换* 格式 ${param1}*/public static void variableReplace(WordprocessingMLPackage wordMLPackage, HashMap<String, String> params) throws JAXBException, Docx4JException{// 提取正文MainDocumentPart main = wordMLPackage.getMainDocumentPart();variableReplace(main, params);}
生成目录
/*** 生成目录* @param wordMLPackage WordprocessingMLPackage* @param index 生成目录位置* @param tocHeadingText 目录标题*/public static void tocGenerator(WordprocessingMLPackage wordMLPackage, int index, String tocHeadingText) throws TocException {TocGenerator tocGenerator = new TocGenerator(wordMLPackage);if(StringUtils.isNotBlank(tocHeadingText)){Toc.setTocHeadingText(tocHeadingText);}// skipPageNumbering如果设置为TRUE 则会联网 要付费tocGenerator.generateToc(index, "TOC \\o \"1-3\" \\h \\z \\u", true);}
构造表格边框样式
/*** 构造表格边框样式* @param style 样式配置* @return CTBorder*/public static CTBorder buildTableBorder(TableBorderStyle style){CTBorder border = new CTBorder();if(StringUtils.isNotBlank(style.getColor())){border.setColor(style.getColor());}if(null != style.getSize()){border.setSz(style.getSize());}if(null != style.getSpace()){border.setSpace(style.getSpace());}STBorder val = null != style.getStyle() ? style.getStyle() : STBorder.SINGLE;border.setVal(val);return border;}
设置表格边框样式
/*** 设置表格边框样式* @param top 上边框* @param bottom 下边框* @param left 左边框* @param right 右边框* @return TblBorders*/public static TblBorders setTableBorder(CTBorder top, CTBorder bottom, CTBorder left, CTBorder right){TblBorders borders = new TblBorders();borders.setBottom(top);borders.setLeft(bottom);borders.setRight(left);borders.setTop(right);
// borders.setInsideH(border);
// borders.setInsideV(border);return borders;}
FontStyle
import lombok.Data;
import org.docx4j.wml.STEm;
import org.docx4j.wml.STShd;
import org.docx4j.wml.STVerticalAlignRun;
import org.docx4j.wml.UnderlineEnumeration;import java.math.BigInteger;/*** 字体样式*/
@Data
public class FontStyle {/** 中文字体 tips:宋体 **/private String cnFontFamily;/** 英文字体 **/private String enFontFamily;/** 字体大小 **/private BigInteger size;/** 字体颜色 **/private String color;/** 是否加粗 **/private Boolean bold;/** 是否斜体 **/private Boolean italic;/** 是否删除线 **/private Boolean deleteLine;/*** 设置下划线* UnderlineEnumeration.SINGLE 单下划线* UnderlineEnumeration.DOUBLE 双下划线* UnderlineEnumeration.DASH 虚线* UnderlineEnumeration.WAVE 波浪线*/private UnderlineEnumeration underlineEnumeration;/** 背景颜色 **/private STShd backgroundColor;/** 字体边框颜色 **/private String borderColor;/** 字体边框大小 **/private BigInteger borderSize;/** 字体边框间距 **/private BigInteger borderSpace;/** 字体边框阴影 **/private Boolean borderShadow;/** 着重号 **/private STEm emphasis;/** 空心 **/private Boolean outline;/** 设置上标下标 **/private STVerticalAlignRun verticalAlign;/** 设置字符间距缩进 **/private Integer indent;/** 设置字符间距信息 **/private BigInteger spacing;/** 设置文本位置 **/private BigInteger position;/** 阴文 **/private Boolean imprint;/** 阳文 **/private Boolean emboss;/** 设置隐藏 **/private Boolean vanish;/** 设置阴影 **/private Boolean shadow;/** 设置底纹 **/private STShd shading;/** 设置突出显示文本 **/private String hightlight;/** 设置单删除线 **/private Boolean strike;/** 设置双删除线 **/private Boolean doubleStrike;/** 倾斜 **/private Boolean tilt;}
TableBorderStyle
import lombok.Data;
import org.docx4j.wml.STBorder;import java.math.BigInteger;/*** 表格边框样式*/
@Data
public class TableBorderStyle {/** 边框大小 **/private BigInteger size;/** 边框间距 **/private BigInteger space;/** 边框颜色 **/private String color;/** 边框样式 **/private STBorder style;
}
7.目录相关操作疑问
目前看 目录如果需要带页码就需要企业版, 还有生成和查找方法,目前找到的都不行,只有这样做法能勉强达到效果,但生成的目录点击跳转不了,求大神指导~~
TocGenerator tocGenerator = new TocGenerator(wordMLPackage);
if(StringUtils.isNotBlank(tocHeadingText)){Toc.setTocHeadingText(tocHeadingText);
}
// skipPageNumbering如果设置为TRUE 则会联网 要付费
tocGenerator.generateToc(index, "TOC \\o \"1-3\" \\h \\z \\u", true);
其他方法如下:
public static void main(String[] args) throws Exception{TocGenerator tocGenerator = new TocGenerator(wordMLPackage);Toc.setTocHeadingText("目录");tocGenerator.generateToc( 3, "TOC \\o \"1-3\"", true);Document wmlDocumentEl = main.getJaxbElement();Body body = wmlDocumentEl.getBody();TocFinder finder = new TocFinder();new TraversalUtil(body.getContent(), finder);System.out.println(finder.getTocSDT().getSdtContent().getContent().size());wordMLPackage.getMainDocumentPart().getDocumentSettingsPart().getJaxbElement().setUpdateFields(new BooleanDefaultTrue());TocGenerator tocGenerator = new TocGenerator(wordMLPackage);tocGenerator.updateToc( true);VariablePrepare.prepare(wordMLPackage);ObjectFactory factory = Context.getWmlObjectFactory();P paragraph = factory.createP();// addFieldBeginaddFieldBegin(factory, paragraph);addTableOfCententField(factory, paragraph);// addFieldEndaddFieldEnd(factory, paragraph);}private static void addFieldBegin(ObjectFactory factory, P paragraph){R run = factory.createR();FldChar fldChar = factory.createFldChar();fldChar.setFldCharType(STFldCharType.BEGIN);fldChar.setDirty(true);run.getContent().add(getWrappendFldChar(fldChar));paragraph.getContent().add(run);}private static void addTableOfCententField(ObjectFactory factory, P paragraph){R run = factory.createR();Text text = new Text();text.setSpace("preserve");text.setValue("TOC \\o \"1-3\" \\h \\z \\u");run.getContent().add(factory.createRInstrText(text));paragraph.getContent().add(run);}private static void addFieldEnd(ObjectFactory factory, P paragraph){R run = factory.createR();FldChar fldChar = factory.createFldChar();fldChar.setFldCharType(STFldCharType.END);fldChar.setDirty(true);run.getContent().add(getWrappendFldChar(fldChar));paragraph.getContent().add(run);}private static JAXBElement getWrappendFldChar(FldChar fldChar){return new JAXBElement(new QName(Namespaces.NS_WORD12, "fldChar"), FldChar.class, fldChar);}
使用docx4j生成数据库字典文档相关推荐
- 如何生成数据库设计文档
如何生成数据库设计文档 screw 什么是screw 特点 支持生成的文档类型 目前支持的数据库类型 支持的模板类型 如何使用? 遇到的问题 screw 官网地址: https://gitee.com ...
- 生成数据库设计文档小技巧
目录 生成数据库设计文档小技巧 利用数据库自身功能生成excel和word文档 使用的软件环境说明 查询所有表名 查询所有列名 设置excel 生成数据库设计文档小技巧 利用数据库自身功能生成exce ...
- 自动生成数据库设计文档利器
目录 1.前言介绍 2.功能说明 3.编码实战 1.新建项目 2.导入依赖 3.启动类 4.工具类 5.测试 1.前言介绍 今天给大家介绍一款非常还用的小工具,专门用到生成数据库设计文档的,非常简单. ...
- Java自动生成数据库设计文档(Word)
一.前言 在日常的开发工作中,偶尔会遇到项目收尾需要提供数据库设计文档的情况.对这个文档的编写目前应该已经基本没有问题了,如果你还不知道如何编写该文档,可以参考如下文章. https://blog.c ...
- mysql自动生成数据库设计文档
mysql生成数据库设计文档 引入jar包 <!-- screw核心 --> <dependency><groupId>cn.smallbun.screw</ ...
- 用PDMReader工具生成数据库设计文档
你是否在为写庞大的数据库设计文档发愁,帮你轻松搞定,前提是你需要有pdm文件! 第一步:下载并安装PDMReader(见我的资源里); 第二步:打开PDMReader,新建项目:test: 第三步:在 ...
- oracle 读取表结构和注释,生成数据库结构文档
有时候建好数据库后要给客户提交数据库结构文档.直接通过一下sql语句生成: select A.column_name 字段名,A.data_type 数据类型,A.data_length 长度, ...
- postgre 生成数据库html文档_还在手动整理数据库文档?试试这个(螺丝钉)数据库文档生成工具...
简介 在企业级开发中.我们经常会有编写数据库表结构文档的时间付出,从业以来,待过几家企业,关于数据库表结构文档状态:要么没有.要么有.但都是手写.后期运维开发,需要手动进行维护到文档中,很是繁琐.如果 ...
- oracle 怎么读取表结构和注释,生成数据库结构文档
有时候建好数据库后要给客户提交数据库结构文档.直接通过一下sql语句生成: select A.column_name 字段名,A.data_type 数据类型,A.data_length 长度, ...
- postgre 生成数据库html文档_还在手动整理数据库文档?试试这个工具
简介 在企业级开发中.我们经常会有编写数据库表结构文档的时间付出,从业以来,待过几家企业,关于数据库表结构文档状态:要么没有.要么有.但都是手写.后期运维开发,需要手动进行维护到文档中,很是繁琐.如果 ...
最新文章
- Javaweb 实验二 JSP应用开发基础
- 【Android必备】与其他碎片进行通信(10)
- The Beam Model:Stream Tables翻译(上)
- 【Java】6.3 类成员
- mac 10.10 apache php,在Mac上10分钟搞定Apache服务器配置
- oracle 并行执行 杀掉会话,oracle – 为什么即使我禁用并行DML和并行DDL也会创建并行会话...
- 20140505 科技脉搏 - “社交”这棵老树,依然在开着新花
- java opencv 之人脸识别
- matlab三轴定位程序,三边测量定位MATLAB源码
- 随机数公式Random
- 计算机毕业设计SSM大学生学科竞赛管理系统【附源码数据库】
- c语言:24、大小端序
- VScode修改html代码后,浏览器页面更新不及时
- AE 二次开发。请考虑更改其中一个程序集的“嵌入互操作类型”属性。
- 数据结构与算法A 查找
- 第二十章 Unity 渲染管线
- 快讯:湘江实验室在长沙揭牌成立;中国移动算网升级3AZ重磅发布
- 16.引言篇——自定义过滤器及标签
- 计算机考研英语复试自我介绍范文,2016考研复试英语自我介绍12篇范文
- AppStore 如何增加销售的心得
热门文章
- GB2312、GB18030、GBK、UNICODE、BIG5之间兼容关系
- 安卓一键清理内存_豆豆清理大师免费下载-豆豆清理大师老年版v1.0.0手机版
- windows station和desktop
- linux的vmstat命令,vmstat命令参数详解
- solidworks_adams_simuilink联合仿真简易教程
- AssetBundle接口详解与优化
- GD32F103VET6替代STM32F103VET6遇到的问题
- 打印机无法打印测试页是什么原因
- Python实现Word文档翻译
- python实现艾宾浩斯背单词功能,实现自动提取单词、邮件发送,部署在阿里云服务器,再也不用担心背单词啦!!