簡體   English   中英

多個評論apache poi

[英]Multiple comments apache poi

我試圖將多個注釋分配給多個單元格。 當打開文件時,excel抱怨“ Excel在...中發現了不可讀的內容,您要恢復此工作簿的內容嗎?”

當我只有一條評論有效時,有2條或更多評論失敗。 請參閱下面的代碼:

    String oper = "OPERATION TO DO AFTER UPLOAD";
    Cell c = row.createCell(0);
    c.setCellType(Cell.CELL_TYPE_STRING);
    c.setCellValue(oper);
    c.setCellStyle(headerStyle);


    CreationHelper factory = wb.getCreationHelper();
    Drawing drawing = sh.createDrawingPatriarch();


//comment for operation
        ClientAnchor anchor = factory.createClientAnchor();
        anchor.setCol1(c.getColumnIndex());
        anchor.setCol2(c.getColumnIndex()+1);
        anchor.setRow1(row.getRowNum());
        anchor.setRow2(row.getRowNum()+3);
        Comment comment = drawing.createCellComment(anchor);
        RichTextString str = factory.createRichTextString("Please note that UPDATE will translate to INSERT (if ENTITY_ID column is empty) or UPDATE (if ENTITY_ID column is a number)");
        comment.setString(str);
        comment.setAuthor("me");
        // Assign the comment to the cell
        c.setCellComment(comment);

        String entity_id = "ENTITY ID";
        c = row.createCell(1);
        c.setCellType(Cell.CELL_TYPE_STRING);
        c.setCellValue(entity_id);
        c.setCellStyle(headerStyle);

        // comment for EntityID

        ClientAnchor anchorEid = factory.createClientAnchor();
        anchorEid.setCol1(c.getColumnIndex());
        anchorEid.setCol2(c.getColumnIndex() + 1);
        anchorEid.setRow1(row.getRowNum());
        anchorEid.setRow2(row.getRowNum() + 3);
        Comment commentEid = drawing.createCellComment(anchorEid);
        RichTextString strEid = factory
                .createRichTextString("Please note that UPDATE will translate to INSERT (if ENTITY_ID column is empty) or UPDATE (if ENTITY_ID column is a number)");
        commentEid.setString(strEid);
        commentEid.setAuthor("me");
        // Assign the comment to the cell
        c.setCellComment(commentEid);

那里是什么問題? 我了解您只需要創建一次繪圖,但是我沒有跨過這個繪圖....

因此,事實證明,在使用SXSSF時,您不能使用注釋(我不應該猜)。 您只能添加一個在電子表格中有效的注釋,這是毫無用處的。

有關詳細信息,請參見位於以下位置的poi文檔表: poi.apache.org/spreadsheet- >它在此處顯示 SXSSF 注釋->否 (嗯,我證明您可以發表1條評論:))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM