有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java显示单词表中的单个水平行

我试图在ApachePOI中显示表中特定行的水平线。使用这个表格,我可以显示所有的水平线,但当我转到特定的行时,我看不到如何做。我使用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;
            }
        }

共 (1) 个答案

  1. # 1 楼答案

    我不完全确定你想画哪条线,但一种典型的给单元格添加边框的方法是

    textCell.setBorderBottom(Borders.NONE);
    

    对于无线和-例如-

    textCell.setBorderBottom(Borders.BASIC_WIDE_MIDLINE);
    

    打个电话

    你也可以这样设置左右边界。这有用吗