简体   繁体   English

如何包含行(使用Apache Poi for Excel)?

[英]how include line (Using Apache Poi for Excel)?

I need to add a line between two existing lines. 我需要在两条现有线之间添加一条线。 I need a new blank line. 我需要一个新的空白行。 Is there some method in poi package for this? poi包中是否有一些方法可以做到这一点?

 public void endossar(String controle) {
    Iterator ite = null;
    try {
        ite = c.conectar("sheet").iterator();
    } catch (IOException ex) {

    }
    while (ite.hasNext()) {
        XSSFRow row = (XSSFRow) ite.next();
        if (row.getCell(0).toString().equals(controle)) {

            row.setRowNum(row.getRowNum()+1);

            // help here, include a new blank line

        }
    }
}

Try to set the row number to the current row number + 2. This should create an empty row: 尝试将行号设置为当前行号+2。这将创建一个空行:

while (ite.hasNext()) {
    XSSFRow row = (XSSFRow) ite.next();
    if (row.getCell(0).toString().equals(controle)) {
        row.setRowNum(row.getRowNum()+2);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM