使用Apache POI添加列到Excel [英] Adding column to Excel using Apache POI

查看:125
本文介绍了使用Apache POI添加列到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用Apache POI在.xlsx文件添加新列。但我没有发现任何东西。有没有办法做到这一点?还是存在任何其他库来解决呢?先谢谢了。

I was wondering about adding new column in a .xlsx file using apache poi. But I could not found any thing. Is there any way to do this? Or is there exists any other library to solve this? Thanks in advance.

推荐答案

有是这样使用Apache POI没有明确的办法。如果知道的行数和所需的列数,则可以首先创建所需的行数,然后创建的行中的相应单元格。你可以参考,如果需要低于code。

There is no explicit way of doing this using apache POI. If you know the number of rows and the number of columns that you need, you can first create the required number of rows and then create the corresponding cells in the rows. You can refer to the code below if needed.

for(row=0;row<maxRowLimit;row++){
    myRow = sheet.getRow(row);
          if (myRow == null) {
            myRow = sheet.createRow(row);
            myCell=myRow.getCell(columnNumber);
            if (myCell == null)
              myRow.createCell(columnNumber); 
          }
}

这篇关于使用Apache POI添加列到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆