poi comment

public static void main(String[] args) {

        try (FileOutputStream out = new FileOutputStream("/Users/chanming/work_note/abc.xls")) {
            HSSFWorkbook wb   = new HSSFWorkbook();
            HSSFSheet sheet   = wb.createSheet("Comment Sheet");
            HSSFPatriarch hpt = sheet.createDrawingPatriarch();
            HSSFCell cell1 = sheet.createRow(3).createCell(1);
            cell1.setCellValue("Excel Comment Example");
            // Setting size and position of the comment in worksheet
            HSSFComment comment1 = hpt.createComment(new HSSFClientAnchor(0, 0, 0, 0, (short) 4, 2, (short) 6, 5));
            // Setting comment text
            comment1.setString(new HSSFRichTextString("hell boy s and girls liyuhang 少年中國"));
            // Associating comment to the cell
            cell1.setCellComment(comment1);
            wb.write(out);
            out.flush();
            out.close();
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
    }
相關文章
相關標籤/搜索