Poi导出Excel插入文本框(TextBox)
2016-09-28 本文已影响82人
f6f54c35b57a
项目中需要导出Excel插入TextBox实现如下效果。
Paste_Image.png
/**
*
*
* 功能描述:excel添加textBox
*
* @param workbook
* 需要添加备注信息的Excel
*
* @param parameter
* 备注信息
*
* @author qianlei
*
* @since 20160926
*
* @update:[变更日期YYYY-MM-DD][更改人姓名][变更描述]
*/
public static void setExcelTextBoxAtFirstSheet(HSSFWorkbook workbook,String text) {
HSSFSheet createSheet = workbook.createSheet("文本框");
// 获得drawingPatriarch
HSSFPatriarch pat = createSheet.createDrawingPatriarch();
// 创建锚点
HSSFClientAnchor anchor = new HSSFClientAnchor(1, 1, 20, 20, (short) 1,1, (short) 20, 20);
HSSFTextbox createTextbox = pat.createTextbox(anchor);
createTextbox.setString(new HSSFRichTextString(text));
}