如何创建Apache的POI 3.6新行? [英] How to create new rows in apache poi 3.6?

查看:169
本文介绍了如何创建Apache的POI 3.6新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache POI 3.6和Java应用程序了。

I am using Apache POI 3.6 and java in our application.

我在行号数据9至30。

I have data in row numbers 9 to 30.

现在,我想包括行号25后的新行做这样后,在26日至30被摧毁旧的数据....我想补充一点,新行不摧毁旧行的数据..

Now, I want to include new rows after the row number 25. After doing like this, the old data in 26 to 30 was destroyed.... I want to add that new rows without destroy the old row's data...

我们可以手动,创建新行只需右键单击行标题像行号25和选择插入鼠标那么它将包含26行,但不删除有关的旧值什么。

We can manually, create new rows by just right click the mouse on the row Header like row number 25 and select insert then it will include the 26 row without deleting anything about the old values.

我是怎么做的编程使用Apache POI和Java?

How I do it programatically using apache poi and java?

推荐答案

首先,你需要开始做一个转变来完成所有的行从25下移

First you need to do move down all the rows from 25 onwards by doing a shift

sheet1.shiftRows(25, sheet1.getLastRowNum(), 5);

这将由5位下移25的所有行

this will move down all rows from 25 by 5 places

然后插入该位置的新行

row1 = sheet1.getRow(25); 
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("text: The new line goes here");

这篇关于如何创建Apache的POI 3.6新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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