HSSFSheet sheet = workbook.createSheet("template page");
// 创建绘图对象
HSSFPatriarch p = sheet.createDrawingPatriarch();
HSSFCellStyle cellStyle = workbook.createCellStyle();
HSSFDataFormat dataFormat = workbook.createDataFormat();
HSSFRow row2 = sheet.createRow(1);
for (int i = 0; i < strData.length; i++) {
HSSFCell cell_1 = row2.createCell((short) i);
cell_1.setCellValue(new HSSFRichTextString(strData[i]));
if (i == 3) {
// 前四个参数是坐标点,后四个参数是编辑和显示批注时的大小.
HSSFComment comment = p.createComment(new HSSFClientAnchor(0,
0, 0, 0, (short) 5, 7, (short) 8, 13));
// 输入批注信息
comment.setString(new HSSFRichTextString(
"system:\n\t1. 必须为SAP中客户编号(新编号)。\n\t2. 必须为10码。\n\t3. 不能为空。"));
comment.setVisible(true);
// 将批注添加到单元格对象中
cell_1.setCellComment(comment);
}
}
HSSFCell cell_2 = row2.createCell((short) 7);
cell_2.setCellValue(12);
cellStyle.setDataFormat(dataFormat.getFormat("####"));
// 前四个参数是坐标点,后四个参数是编辑和显示批注时的大小.
HSSFComment comment = p.createComment(new HSSFClientAnchor(0, 0, 0, 0,
(short) 10, 7, (short) 12, 13));
// 输入批注信息
comment.setString(new HSSFRichTextString(
"system:\n\t1. 不能为空.\n\t2. 不能为负数"));
comment.setVisible(true);
// 将批注添加到单元格对象中
cell_2.setCellComment(comment);