java - 在单词表中显示单独的水平线

标签 java apache-poi

我正在尝试显示 Apache-POI 中表中特定行的水平线。使用表格,我可以显示所有水平线,但是当我转到特定行时,我看不到如何操作。我使用 getTable 但它再次适用于整个表:(

有人可以帮我解决这个问题吗?

        XWPFTableRow tableRow = table.createRow();
        tableRow.getTable().setInsideHBorder(XWPFBorderType.SINGLE,10, 5,    "1C7331");

        for (int col=0; col<3; col++){
            tableCell = tableRow.getCell(col);
            tableCell.removeParagraph(0);
            textCell = tableCell.addParagraph();
            textCell.setAlignment(ParagraphAlignment.LEFT);
            textCell.setIndentFromLeft(50);
            run= textCell.createRun();
            run.setBold(true);
            switch(col){
                case 0: run.setText(plantingDate);
                        break;
                case 1: run.setBold(false);
                        run.setText(sampleName);
                        break;
                case 2: run.setBold(false);
                        run.setText(sample.getCount());
                        break;
            }
        }

最佳答案

我不完全确定您要绘制哪些线条,但向单元格添加边框的典型方法是

textCell.setBorderBottom(Borders.NONE);

对于没有线路和 - 例如 -

textCell.setBorderBottom(Borders.BASIC_WIDE_MIDLINE);

一行。

您还可以像这样设置左右边框。这有帮助吗?

关于java - 在单词表中显示单独的水平线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45834468/

相关文章:

java - 我可以解析日期以适合字符串数组吗?

java - 初始化 map <Foo,Vector<Bar>> - Java 7

java - 如何使用 apache poi 在 excel 中将日期设置为类型日期?

java - NoClassDefFoundError : UnsupportedFileFormatException while using apache poi to write to an excel file

android - 如何将Poi jar文件添加到android studio 1.0.1

Java - 对定期清除的本地值存储的多线程访问

java - 当我尝试将我的应用程序连接到网络服务时失败

Java 外部类加载 ClassDefNotFoundError

java - POI XSSF 是否仍然存在疯狂的错误内存问题?

Java POI - 任何人都能够从公式单元格中提取数字?