相关疑难解决方法(0)

如何使用HSSF(Apache POI)在现有Excel中的两行之间插入行

不知何故,我设法在现有的excel文件中的两行之间创建新行.问题是,一些格式化不包括行的移位.

其中之一就是隐藏的行在转换期间不是相对的.我的意思是(例如),隐藏了20到30行,但是当创建新行时,仍然存在格式化.隐藏的行也必须在插入/创建新行期间移动,它应该是21到31.

另一件事是,工作表中的另一个对象不在单元格中.在创建新行之后,文本框不会移动.它就像这些物体的位置是固定的.但我希望它移动,就像我在excel中插入新行或粘贴行一样.如果有插入新行的功能,请告诉我.

这就是我现在所拥有的,只是我代码中的一个片段.

HSSFWorkbook wb = new HSSFWorkbook(template); //template is the source of file
HSSFSheet sheet = wb.getSheet("SAMPLE");
HSSFRow newRow;
HSSFCell cellData;

int createNewRowAt = 9; //Add the new row between row 9 and 10

sheet.shiftRows(createNewRowAt, sheet.getLastRowNum(), 1, true, false);
newRow = sheet.createRow(createNewRowAt);
newRow = sheet.getRow(createNewRowAt);
Run Code Online (Sandbox Code Playgroud)

如果可以复制和粘贴行,那将是很大的帮助.但是我已经在这里问过它并且找不到解决方案.所以我决定创建一个行作为临时解决方案.我已经完成了它,但有这样的问题.

任何帮助都感激不尽.谢谢!

java excel poi-hssf apache-poi

52
推荐指数
4
解决办法
9万
查看次数

如何使用apache poi为3个单元格设置注释

我想使用Apache POI为3个excel单元格设置注释.

这是我的源代码:

import java.io.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;

public class CellComments
{
    public static void main(String[] args) throws IOException  {

      HSSFWorkbook wb = new HSSFWorkbook();
      HSSFSheet sheet = wb.createSheet("Cell comments in POI HSSF");


      HSSFPatriarch patr = sheet.createDrawingPatriarch();
      HSSFCell cell1 = sheet.createRow(3).createCell((short)1);
      cell1.setCellValue(new HSSFRichTextString("Hello, World"));

      //anchor defines size and position of the comment in worksheet
      HSSFComment comment1 = patr.createComment(new HSSFClientAnchor(100, 100, 100, 100, (short)1, 1, (short) 6, 5));
      comment1.setString(new HSSFRichTextString("FirstComments"));
      cell1.setCellComment(comment1);
      System.out.println("Cell comments: "+cell1.getCellComment().getString());

      patr = sheet.createDrawingPatriarch();
      comment1 = patr.createComment(new …
Run Code Online (Sandbox Code Playgroud)

java apache-poi

2
推荐指数
1
解决办法
5658
查看次数

标签 统计

apache-poi ×2

java ×2

excel ×1

poi-hssf ×1