In normal excel one can name a cell (or a range) using the little text box in the top left part of the sheet, so for example one could name a cell from H13 to "total".
Is there a way to do that through Apache开发者_如何学运维 POI?
From the POI 'Busy Developer's User Guide'
// setup code
String sname = "TestSheet", cname = "TestName", cvalue = "TestVal";
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(sname);
sheet.createRow(0).createCell((short) 0).setCellValue(cvalue);
// 1. create named range for a single cell using areareference
Name namedCell = wb.createName();
namedCell.setNameName(cname);
String reference = sname+"!A1:A1"; // area reference
namedCell.setRefersToFormula(reference);
精彩评论