itext导出word表格,设置表格虚线边框
这个表格去掉了单元格之间的纵向分隔线 第 第 第一 二 三列 列 列这个表格去掉了单元格之间的横向分隔线横 线竖 线都 没 了这个表格去掉了单元格之间的纵向分隔线和横向分隔线 其实上面的三个表格都有三行三列,隐藏分隔线的诀窍在于rules,察看这三个表格的源代码,我们可以看到标签中都有rules。
它有三个参数(cols,rows,none),当rules=cols时,表格会隐藏纵向的分隔线,这样我们就只能看到表格的行;当rules=rows时,则 隐藏了横向的分隔线,这样我们只能看到表格的列;而当rules=none时,纵向分隔线和横向分隔线将全部隐藏。
itext设置表格行高
public static void main(String[] args) throws Exception { // 创建word文档,并设置纸张的大小 Document document = new Document(PageSize.A4); RtfWriter2.getInstance(document, new FileOutputStream( "D:/test/word.doc")); // 打开document document.open(); // 设置字体,字号,加粗,颜色 Font font = new Font(Font.NORMAL, 20, Font.BOLD, new Color(255, 0, 0)); // 设置新的段落,使其字体为font Paragraph p = new Paragraph("出口合同", font); // 设置段落居中,其中1为居中对齐,2为右对齐,3为左对齐 p.setAlignment(1); // 文档中加入该段落 document.add(p); font = new Font(Font.NORMAL, 16, Font.NORMAL, new Color(0, 0, 0)); p = new Paragraph( " 南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院南京大学软件学院", font); // 设置段落缩进 p.setIndentationLeft(10); // 设置首行缩进 p.setFirstLineIndent(20f); // 设置段后距和段前距 p.setSpacingAfter(10f); p.setSpacingBefore(100f); document.add(p); p = new Paragraph("徐州审委会", font); document.add(p); // 创建有三列的表格 Table table = new Table(2, 3); // 设置table的边框宽度为0 table.setBorderWidth(1f); table.setAbsWidth("120px"); // 其中1为居中对齐,2为右对齐,3为左对齐 table.setAlignment(2); // table.setPadding(0); // table.setSpacing(0); // 读取图片(参数为gif、jpg、png格式的图片都可以),设置图片大小 Image image = Image.getInstance("D:/test/1.jpg"); // Image img = Image.getInstance(new URL("http://xxx.com/logo.jpg)"); // 设置图片的绝对大小,宽和高 image.scaleAbsolute(50f, 50f); // 设置图片居中显示 image.setAlignment(Image.MIDDLE); // 创建单元格,并且将单元格内容设置为图片 Cell cell = new Cell(image); // 设置单元格边框为0 cell.setBorder(0); // cell.setHeader(true); // cell.setColspan(3);// 设置表格为三列 // cell.setRowspan(3);// 设置表格为三行 table.addCell(cell); // table.endHeaders();// 表头结束 table.addCell(cell); table.addCell(cell); cell = new Cell("我是田有朋"); // cell.setWidth("10px"); table.addCell(cell); // cell.setBorder(1); // 设置垂直居中 cell.setVerticalAlignment(1); // 设置水平居中 cell.setHorizontalAlignment(1); // document.add(new Paragraph("用java生成word文件")); document.add(table); // 关闭document document.close(); }。
itext设置表格无边框怎么设置
1. 通过设置表格的边框,可以实现! public static PdfPCell createCellTL(String value,int align, Font font,int colspan) { //上左有边框的表格:1.表格内容;2.字体;3.对齐方式;4.横跨列数PdfPCell cell = new PdfPCell();//cell.setVerticalAlignment(Element.ALIGN_MIDDLE);cell.setHorizontalAlignment(align); //水平对齐cell.setColspan(colspan);cell.setPhrase(new Phrase(value,textfont)); //设置表格的短语cell.setPadding(5.0f); //设置内间距cell.disableBorderSide(2); //隐藏下右边框cell.disableBorderSide(8);return cell;}。
java导出word表格
首先我用的技术是 poi 这是代码,一个工具类得调用 public class WordUtil { /** * 基于模板文件导出 word 文档,此方法主要是用来处理文档中需要替换的文本内容,对图片和表格无效 * * @param templatePath * 模板文件的路径,要求路径中要包含全名,并且模板文件只能是 07 及以上格式,即 docx 的文件 * @param destFilePath * 导出文件的存放路径,包含文件名,例如,E:/test/小区公告.docx * @param data * 用来替换文档中预定义的字符串,要求预定义的字符串与 data 中的 key 值要相同 */ public static void exportWordByTemplate(String templatePath, String destFilePath, Map E:/test/test.doc 新生成的地址。 转载请注明出处51数据库 » itextword表格
疯了10