获取第一行
HSSFRow taskRow = sheet.getRow(0);
获取第一行第一个单元格
HSSFCell cell = taskRow.getCell(0);
锁定Excel
HSSFWorkbook workbook = new HSSFWorkbook(); //构建excel对象
HSSFSheet sheet=workbook.createSheet(“sheet工作簿的名字”); //创建工作簿
sheet.protectSheet("edit");
解锁及参考 : https://blog.csdn.net/u012270682/article/details/47170591
设置第一列宽度
sheet.setColumnWidth(0, 30 * 256);
超链接
HSSFCell cell1 = row.createCell(3);
HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
link.setAddress("https://github.com/550690513");
cell1.setHyperlink(link);// 设置超链接
cell1.setCellValue("Fork me on Github");
样式(设置边框/字体/颜色/加粗/居中/)
https://blog.csdn.net/sinat_34093604/article/details/53432545
扫描二维码关注公众号,回复:
3678302 查看本文章
换行
https://blog.csdn.net/u013769145/article/details/50721356/
水平居中和垂直居中
//创建单元格,并设置值表头 设置表头居中
HSSFCellStyle styleTitle = wokbook.createCellStyle();
//水平居中
styleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//垂直居中
styleTitle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
列宽设置
sheet.setColumnWidth(0, 70 * 256);// 第一列宽度
行高设置
row.setHeight((short) 1000);
合并单元格