poi生成javadoc文档doc文档怎么设置字体

poi 读取excel 复制到新的excel sheet页中 怎么复制单元格内字体样式
poi 读取excel 复制到新的excel sheet页中 怎么复制单元格内字体样式
//获得传入的excel的字体的样式
HSSFFont font = row.getCell(j).getCellStyle().getFont(workbook);
//生成新的字体
HSSFFont fonts = wbCreat.createFont();
fonts.setFontHeightInPoints(font.getFontHeightInPoints()); //设置字体大小
fonts.setColor(font.getColor()); //设置字体颜色
fonts.setFontName(font.getFontName()); //设置子是什么字体(如宋体)
fonts.setBoldweight(font.getBoldweight()); //设置粗体
cellStyle.setFont(fonts);//将字体样式设置给单元格
比如你有一个 CellStyle style1, 要从 CellStyle style2 拷贝样式。
style1.cloneStyleFrom(style2)
因为字体也在样式里,所以应该可以拷贝字体样式
具体还可以参考
相关标签:
分享即可 +1积分
请登录后,发表评论
评论(Enter+Ctrl)
评论加载中...
评论加载中...
1.多思,多做,多玩,3What,WHy,HOw,YYYYYY学无止尽,记录点滴,重要的事情先做。2.分享经验。csdn没有收藏的内容问题,记录到慕课手记
3.每日微博分享2次,评价课程
作者的热门手记
Copyright (C)
All Rights Reserved | 京ICP备 号-2poi生成word文件 - 王朝网络 -
分享&&&&&当前位置: &&&&&&&&poi生成word文件&&&  一、简介  对于poi来说,poi可以完成对Word、Excel、PPT的处理。word目前有两种文件格式,一种是doc后缀、另一种是docx后缀的。2007之前的版本都是doc后缀的,这种格式poi使用HWPF进行处理。HWPF也能有限多地对旧的word6和word95格式的文件处理提供支持。2007(包括)之后都是docx后缀的,poi使用XWPF进行处理。HWPF 和 XWPF的特性有些相似,但是目前两者没有共用接口。  HWPF和XWPF可以被描述为&适度功能&。对于一些例子来说,管理文本的提取,提供强有力的支持。对于其他莱斯,支持是有限或不完整的,需要深入研究低级别的代码。错误检测已经被移除,所有可能会创建格式错误的文件。  HWPF 包含在poi-scratchpad-XXX.jar包中,而XWPF 包含在 poi-ooxml-XXX.jar包中。我们可以根据我们的需要来将这些包添加都classpath里面。HWPF与XWPF网址为:http://poi.apache.org/document/index.html 。  二、实例  1、依赖如下:  &dependency&&groupId&org.apache.poi&/groupId&&artifactId&poi&/artifactId&&version&3.12&/version&&/dependency&&dependency&&groupId&org.apache.poi&/groupId&&artifactId&poi-ooxml&/artifactId&&version&3.12&/version&&/dependency&&dependency&&groupId&org.apache.poi&/groupId&&artifactId&poi-scratchpad&/artifactId&&version&3.12&/version&&/dependency&  2、示例代码如下:  1packagecom.test.23importjava.io.FileOutputS4importjava.io.IOE5importjava.math.BigI6importjava.util.L78importorg.apache.poi.xwpf.usermodel.ParagraphA9importorg.apache.poi.xwpf.usermodel.TextA10importorg.apache.poi.xwpf.usermodel.XWPFD11importorg.apache.poi.xwpf.usermodel.XWPFP12importorg.apache.poi.xwpf.usermodel.XWPFR13importorg.apache.poi.xwpf.usermodel.XWPFT14importorg.apache.poi.xwpf.usermodel.XWPFTableC15importorg.junit.T16importorg.openxmlformats.schemas.wordPRocessingml.x2006.main.CTTblPr;17importorg.openxmlformats.schemas.wordprocessingml.x2006.main.STTblW1819/**20* 创建word文档21*/22publicclassWordCreate {23/**24* 2007word文档创建25*/26@Test27publicvoidcreateWord2007() {28XWPFDocument doc =newXWPFDocument();29XWPFParagraph p1 =doc.createParagraph();3031XWPFTable table = doc.createTable(11, 4);32//CTTblBorders borders=table.getCTTbl().getTblPr().addNewTblBorders();33CTTblPr tblPr =table.getCTTbl().getTblPr();34tblPr.getTblW().setType(STTblWidth.DXA);35tblPr.getTblW().setW(newBigInteger("7000"));3637//设置上下左右四个方向的距离,可以将表格撑大38table.setCellMargins(20, 20, 20, 20);3940//表格41List&XWPFTableCell& tableCells = table.getRow(0).getTableCells();4243XWPFTableCell cell = tableCells.get(0);44XWPFParagraph newPara =newXWPFParagraph(cell.getCTTc().addNewP(), cell);45XWPFRun run =newPara.createRun();46/**内容居中显示 **/47newPara.setAlignment(ParagraphAlignment.CENTER);48//run.getCTR().addNewRPr().addNewColor().setVal("FF0000");/**FF0000红色*/49//run.setUnderline(UnderlinePatterns.THICK);50run.setText("第一 数据");5152tableCells.get(1).setText("第一 数据");53tableCells.get(2).setText("第一 据");54tableCells.get(3).setText("第 据");5556tableCells = table.getRow(1).getTableCells();57tableCells.get(0).setText("第数据");58tableCells.get(1).setText("第一 数据");59tableCells.get(2).setText("第一 据");60tableCells.get(3).setText("第 据");6162//设置字体对齐方式63p1.setAlignment(ParagraphAlignment.CENTER);64p1.setVerticalAlignment(TextAlignment.TOP);6566//第一页要使用p1所定义的属性67XWPFRun r1 =p1.createRun();6869//设置字体是否加粗70r1.setBold(true);71r1.setFontSize(20);7273//设置使用何种字体74r1.setFontFamily("Courier");7576//设置上下两行之间的间距77r1.setTextPosition(20);78r1.setText("标题");7980FileOutputS81try{82out =newFileOutputStream("c:/test/word2007.docx");83//以下代码可进行文件下载84//response.reset();85//response.setContentType("application/x-msdownloadoctet-charset=utf-8");86//response.setHeader("Content-Disposition",87//"filename=\"" + URLEncoder.encode(fileName, "UTF-8"));88//OutputStream out = response.getOutputStream();89//this.doc.write(out);90//out.flush();9192doc.write(out);93out.close();94}catch(IOException e) {95e.printStackTrace();96}97System.out.println("success");98}99100}  3、生成word如下所示  &&&&&今日推荐
&&&&&日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。
最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。
歌手:Def...老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...把牛仔裤磨出有线的破洞
1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...先来看下敬业福和爱国福
今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。
今天该活动正式启动,和去年一样,需要收集“五福”...有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。
1、很多人有这种习...简介
《极品家丁》讲述了现代白领林晚荣无意回到古代金陵,并追随萧二小姐化名“林三”进入萧府,不料却阴差阳错上演了一出低级家丁拼搏上位的“林三升职记”。...你就是我最爱的宝宝 - 李溪芮
(电视剧《极品家丁》片尾曲)
作词:常馨内
作曲:常馨内
你的眉 又鬼马的挑
你的嘴 又坏坏的笑
上一秒吵闹 下...乌梅,又称春梅,中医认为,乌梅味酸,性温,无毒,具有安心、除热、下气、祛痰、止渴调中、杀虫的功效,治肢体痛、肺痨病。乌梅泡水喝能治伤寒烦热、止吐泻,与干姜一起制...什么是脂肪粒
在我们的脸上总会长一个个像脂肪的小颗粒,弄也弄不掉,而且颜色还是白白的。它既不是粉刺也不是其他的任何痘痘,它就是脂肪粒。
脂肪粒虽然也是由油脂...来源:中国青年报
新的攻击方法不断涌现,黑客几乎永远占据网络攻击的上风,我们不可能通过技术手段杜绝网络攻击。国家安全保障的主要方向是打击犯罪,而不是处置和惩罚...夫妻网络直播“造人”爆红
  1月9日,温岭城北派出所接到南京警方的协查通告,他们近期打掉了一个涉黄直播APP平台。而根据掌握的线索,其中有一对涉案的夫妻主播...如何防止墙纸老化?
(1)选择透气性好的墙纸
市场上墙纸的材质分无纺布的、木纤维的、PVC的、玻璃纤维基材的、布面的等,相对而言,PVC材质的墙纸最不透气...观点一:破日本销售量的“鲜肌之谜” 非日本生产
近一段时间,淘宝上架了一款名为“鲜肌之谜的” 鲑鱼卵巢美容液,号称是最近日本的一款推出的全新护肤品,产品本身所...系腰裙(北宋词人 张先)
惜霜蟾照夜云天,朦胧影、画勾阑。人情纵似长情月,算一年年。又能得、几番圆。
欲寄西江题叶字,流不到、五亭前。东池始有荷新绿,尚小如...关于女人的经典语句1、【做一个独立的女人】
思想独立:有主见、有自己的人生观、价值观。有上进心,永远不放弃自己的理想,做一份自己喜爱的事业,拥有快乐和成就...你想体验机器人性爱吗?你想和性爱机器人结婚吗?如果你想,机器人有拒绝你的权利吗?
近日,第二届“国际人类-机器人性爱研讨会”大会在伦敦金史密斯大学落下帷幕。而...10.土耳其地下洞穴城市
变态指数:★★☆☆☆
这是土耳其卡帕多西亚的一个著名景点,传说是当年基督教徒们为了躲避战争而在此修建。里面曾住着20000人,......据英国《每日快报》报道,一位科学家兼理论家Robert Lanza博士宣称,世界上并不存在人类死亡,死亡的只是身体。他认为我们的意识借助我们体内的能量生存,而且...《我爱狐狸精》 - 刘馨棋
  (电视剧《屏里狐》主题曲)
  作词:金十三&李旦
  作曲:刘嘉
  狐狸精 狐狸仙
  千年修...·&·&·&&&&&&一、简介
对于poi来说,poi可以完成对Word、Excel、PPT的处理。word目前有两种文件格式,一种是doc后缀、另一种是docx后缀的。2007之前的版本都是doc后缀的,这种格式poi使用HWPF进行处理。HWPF也能有限多地对旧的word6和word95格式的文件处理提供支持。2007(包括)之后都是docx后缀的,poi使用XWPF进行处理。HWPF 和 XWPF的特性有些相似,但是目前两者没有共用接口。
HWPF和XWPF可以被描述为&适度功能&。对于一些例子来说,管理文本的提取,提供强有力的支持。对于其他莱斯,支持是有限或不完整的,需要深入研究低级别的代码。错误检测已经被移除,所有可能会创建格式错误的文件。
HWPF 包含在poi-scratchpad-XXX.jar包中,而XWPF 包含在 poi-ooxml-XXX.jar包中。我们可以根据我们的需要来将这些包添加都classpath里面。HWPF与XWPF网址为:http://poi.apache.org/document/index.html 。
1、依赖如下:
&dependency&&groupId&org.apache.poi&/groupId&&artifactId&poi&/artifactId&&version&3.12&/version&&/dependency&&dependency&&groupId&org.apache.poi&/groupId&&artifactId&poi-ooxml&/artifactId&&version&3.12&/version&&/dependency&&dependency&&groupId&org.apache.poi&/groupId&&artifactId&poi-scratchpad&/artifactId&&version&3.12&/version&&/dependency&
2、示例代码如下:
1packagecom.test.23importjava.io.FileOutputS4importjava.io.IOE5importjava.math.BigI6importjava.util.L78importorg.apache.poi.xwpf.usermodel.ParagraphA9importorg.apache.poi.xwpf.usermodel.TextA10importorg.apache.poi.xwpf.usermodel.XWPFD11importorg.apache.poi.xwpf.usermodel.XWPFP12importorg.apache.poi.xwpf.usermodel.XWPFR13importorg.apache.poi.xwpf.usermodel.XWPFT14importorg.apache.poi.xwpf.usermodel.XWPFTableC15importorg.junit.T16importorg.openxmlformats.schemas.wordPRocessingml.x2006.main.CTTblPr;17importorg.openxmlformats.schemas.wordprocessingml.x2006.main.STTblW1819/**20* 创建word文档21*/22publicclassWordCreate {23/**24* 2007word文档创建25*/26@Test27publicvoidcreateWord2007() {28XWPFDocument doc =newXWPFDocument();29XWPFParagraph p1 =doc.createParagraph();3031XWPFTable table = doc.createTable(11, 4);32//CTTblBorders borders=table.getCTTbl().getTblPr().addNewTblBorders();33CTTblPr tblPr =table.getCTTbl().getTblPr();34tblPr.getTblW().setType(STTblWidth.DXA);35tblPr.getTblW().setW(newBigInteger("7000"));3637//设置上下左右四个方向的距离,可以将表格撑大38table.setCellMargins(20, 20, 20, 20);3940//表格41List&XWPFTableCell& tableCells = table.getRow(0).getTableCells();4243XWPFTableCell cell = tableCells.get(0);44XWPFParagraph newPara =newXWPFParagraph(cell.getCTTc().addNewP(), cell);45XWPFRun run =newPara.createRun();46/**内容居中显示 **/47newPara.setAlignment(ParagraphAlignment.CENTER);48//run.getCTR().addNewRPr().addNewColor().setVal("FF0000");/**FF0000红色*/49//run.setUnderline(UnderlinePatterns.THICK);50run.setText("第一 数据");5152tableCells.get(1).setText("第一 数据");53tableCells.get(2).setText("第一 据");54tableCells.get(3).setText("第 据");5556tableCells = table.getRow(1).getTableCells();57tableCells.get(0).setText("第数据");58tableCells.get(1).setText("第一 数据");59tableCells.get(2).setText("第一 据");60tableCells.get(3).setText("第 据");6162//设置字体对齐方式63p1.setAlignment(ParagraphAlignment.CENTER);64p1.setVerticalAlignment(TextAlignment.TOP);6566//第一页要使用p1所定义的属性67XWPFRun r1 =p1.createRun();6869//设置字体是否加粗70r1.setBold(true);71r1.setFontSize(20);7273//设置使用何种字体74r1.setFontFamily("Courier");7576//设置上下两行之间的间距77r1.setTextPosition(20);78r1.setText("标题");7980FileOutputS81try{82out =newFileOutputStream("c:/test/word2007.docx");83//以下代码可进行文件下载84//response.reset();85//response.setContentType("application/x-msdownloadoctet-charset=utf-8");86//response.setHeader("Content-Disposition",87//"filename=\"" + URLEncoder.encode(fileName, "UTF-8"));88//OutputStream out = response.getOutputStream();89//this.doc.write(out);90//out.flush();9192doc.write(out);93out.close();94}catch(IOException e) {95e.printStackTrace();96}97System.out.println("success");98}99100}
3、生成word如下所示
&&&&&  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。&&&&&&为你推荐&&&&&&转载本文&UBB代码&HTML代码复制到剪贴板...&更多内容··········&&&&&&&&&频道精选&&&王朝女性&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝分栏&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝编程&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝导购&&|&&|&&|&&|&&|&&|&&|&&|&&|&&|&王朝其他&&|&&|&&|&&|&&|&&|&&&&2005-&&版权所有&POI设置word 2007文本下划线样式及文字底纹 - 推酷
POI设置word 2007文本下划线样式及文字底纹
直接上代码
import java.io.FileOutputS
import java.math.BigI
import java.util.R
import org.apache.poi.xwpf.usermodel.BreakT
import org.apache.poi.xwpf.usermodel.ParagraphA
import org.apache.poi.xwpf.usermodel.TextA
import org.apache.poi.xwpf.usermodel.XWPFD
import org.apache.poi.xwpf.usermodel.XWPFP
import org.apache.poi.xwpf.usermodel.XWPFR
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTB
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTF
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTH
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsM
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTS
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTS
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTU
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightC
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingR
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STS
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STU
public class POI_07_设置下划线样式_S3_Test {
public static void main(String[] args) throws Exception {
POI_07_设置下划线样式_S3_Test t = new POI_07_设置下划线样式_S3_Test();
XWPFDocument doc = new XWPFDocument();
// 需关闭护眼色才能看到效果
t.setDocumentbackground(doc, &FDE9D9&);//设置页面背景色
t.testSetUnderLineStyle(doc);//设置下划线样式以及突出显示文本
t.addNewPage(doc, BreakType.PAGE);
t.testSetShdStyle(doc);//设置文字底纹
t.saveDocument(doc,
&f:/saveFile/temp/sys_& + System.currentTimeMillis() + &.docx&);
public void testSetUnderLineStyle(XWPFDocument doc) {
String[] colors = new String[] { &CCA6EF&, &DD999D&, &4FCEF0&,
&7A7A7A&, &F3C917&, &FFA932&, &C7B571&, &535354&, &5FD2F1&,
&B5E900&, &FEF8B6& };
Random random = new Random();
// TODO 这里为了方便测试写了数字,推荐写英文样式
for (int i = 1; i &= 18; i++) {
XWPFParagraph p = doc.createParagraph();
setParagraphFontInfoAndUnderLineStyle(p, &测试下划线&, &宋体&, &1D8C56&,
&22&, false, false, false, true, i,
colors[Math.abs(random.nextInt(colors.length))], false, 0,
setParagraphSpacingInfo(p, true, &0&, &50&, false, &0&, &0&, true,
&240&, STLineSpacingRule.Enum.forString(&auto&));
setParagraphAlignInfo(p, ParagraphAlignment.LEFT,
TextAlignment.CENTER);
public void testSetShdStyle(XWPFDocument doc) {
String[] colors = new String[] { &CCA6EF&, &DD999D&, &4FCEF0&,
&7A7A7A&, &F3C917&, &FFA932&, &C7B571&, &535354&, &5FD2F1&,
&B5E900&, &FEF8B6& };
Random random = new Random();
// TODO 这里为了方便测试写了数字,推荐写英文样式
for (int i = 1; i &= 38; i++) {
XWPFParagraph p = doc.createParagraph();
setParagraphFontInfoAndUnderLineStyle(p, &测试底纹&, &宋体&, &1D8C56&,
&22&, false, false, false, false, i, null, true, i,
colors[Math.abs(random.nextInt(colors.length))]);
setParagraphSpacingInfo(p, true, &0&, &50&, false, &0&, &0&, true,
&240&, STLineSpacingRule.Enum.forString(&auto&));
setParagraphAlignInfo(p, ParagraphAlignment.LEFT,
TextAlignment.CENTER);
public void setParagraphAlignInfo(XWPFParagraph p,
ParagraphAlignment pAlign, TextAlignment valign) {
p.setAlignment(pAlign);
p.setVerticalAlignment(valign);
public void setParagraphSpacingInfo(XWPFParagraph p, boolean isSpace,
String before, String after, boolean isPLine, String beforeLines,
String afterLines, boolean isLine, String line,
STLineSpacingRule.Enum lineValue) {
CTPPr pPPr =
if (p.getCTP() != null) {
if (p.getCTP().getPPr() != null) {
pPPr = p.getCTP().getPPr();
pPPr = p.getCTP().addNewPPr();
CTSpacing pSpacing = pPPr.getSpacing() != null ? pPPr.getSpacing()
: pPPr.addNewSpacing();
if (isSpace) {
// 段前磅数
if (before != null) {
pSpacing.setBefore(new BigInteger(before));
// 段后磅数
if (after != null) {
pSpacing.setAfter(new BigInteger(after));
if (isPLine) {
// 段前行数
if (beforeLines != null) {
pSpacing.setBeforeLines(new BigInteger(beforeLines));
// 段后行数
if (afterLines != null) {
pSpacing.setAfterLines(new BigInteger(afterLines));
if (isLine) {
if (line != null) {
pSpacing.setLine(new BigInteger(line));
if (lineValue != null) {
pSpacing.setLineRule(lineValue);
public void setParagraphFontInfoAndUnderLineStyle(XWPFParagraph p,
String content, String fontFamily, String colorVal,
String fontSize, boolean isBlod, boolean isItalic,
boolean isStrike, boolean isUnderLine, int underLineStyle,
String underLineColor, boolean isShd, int shdValue, String shdColor) {
XWPFRun pRun =
if (p.getRuns() != null && p.getRuns().size() & 0) {
pRun = p.getRuns().get(0);
pRun = p.createRun();
pRun.setText(content);
CTRPr pRpr =
if (pRun.getCTR() != null) {
pRpr = pRun.getCTR().getRPr();
if (pRpr == null) {
pRpr = pRun.getCTR().addNewRPr();
// 设置字体
CTFonts fonts = pRpr.isSetRFonts() ? pRpr.getRFonts() : pRpr
.addNewRFonts();
fonts.setAscii(fontFamily);
fonts.setEastAsia(fontFamily);
fonts.setHAnsi(fontFamily);
// 设置字体大小
CTHpsMeasure sz = pRpr.isSetSz() ? pRpr.getSz() : pRpr.addNewSz();
sz.setVal(new BigInteger(fontSize));
CTHpsMeasure szCs = pRpr.isSetSzCs() ? pRpr.getSzCs() : pRpr
.addNewSzCs();
szCs.setVal(new BigInteger(fontSize));
// 设置字体样式
if (isBlod) {
pRun.setBold(isBlod);
if (isItalic) {
pRun.setItalic(isItalic);
if (isStrike) {
pRun.setStrike(isStrike);
if (colorVal != null) {
pRun.setColor(colorVal);
// 设置字突出显示文本
if (underLineStyle & 0 && underLineStyle & 17) {
CTHighlight hightLight = pRpr.isSetHighlight() ? pRpr
.getHighlight() : pRpr.addNewHighlight();
hightLight.setVal(STHighlightColor.Enum.forInt(underLineStyle));
// 设置下划线样式
if (isUnderLine) {
CTUnderline u = pRpr.isSetU() ? pRpr.getU() : pRpr.addNewU();
u.setVal(STUnderline.Enum.forInt(Math.abs(underLineStyle % 19)));
if (underLineColor != null) {
u.setColor(underLineColor);
if (isShd) {
// 设置底纹
CTShd shd = pRpr.isSetShd() ? pRpr.getShd() : pRpr.addNewShd();
if (shdValue & 0 && shdValue &= 38) {
shd.setVal(STShd.Enum.forInt(underLineStyle));
if (shdColor != null) {
shd.setColor(shdColor);
// 设置页面背景色
public void setDocumentbackground(XWPFDocument document, String bgColor) {
CTBackground bg = document.getDocument().isSetBackground() ? document
.getDocument().getBackground() : document.getDocument()
.addNewBackground();
bg.setColor(bgColor);
public void addNewPage(XWPFDocument document, BreakType breakType) {
XWPFParagraph xp = document.createParagraph();
xp.createRun().addBreak(breakType);
public void saveDocument(XWPFDocument document, String savePath)
throws Exception {
FileOutputStream fos = new FileOutputStream(savePath);
document.write(fos);
fos.close();
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致6561人阅读
Apache POI(10)
POI 设置字体内容和位置,以下是实例:
HSSFFont f &= wb.createFont(); & &
f.setFontHeightInPoints((short) 11);//字号 & & &
f.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);//加粗 & & &
HSSFCellStyle style = wb.createCellStyle(); &
style.setFont(f); & & &
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);//左右居中 & & &
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//上下居中 & & &
style.setRotation(short rotation);//单元格内容的旋转的角度 & & &
HSSFDataFormat df = wb.createDataFormat(); & &&&
style1.setDataFormat(df.getFormat(&0.00%&));//设置单元格数据格式 & & &
cell.setCellFormula(string);//给单元格设公式 & & &
style.setRotation(short rotation);//单元格内容的旋转的角度 &&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:258520次
积分:2923
积分:2923
排名:第10298名
原创:117篇
评论:16条
(3)(3)(5)(24)(66)(4)(1)(1)(2)(1)(1)(2)(5)

我要回帖

更多关于 poi中文帮助文档 的文章

 

随机推荐