java poi excel导出怎么制作标题
1个回答
展开全部
完整的例子就是这样的。样式自己加上就行了。
public static void main(String[] args) throws IOException {
String excelPath="d:/test.xls";//excel输出路径
File excel=new File(excelPath);
OutputStream out=new FileOutputStream(excel);
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("标签名");
HSSFRow firstHeaderRow=sheet.createRow(0);// 第一行
sheet.addMergedRegion(new CellRangeAddress(0,0,0,8));
HSSFCell yearCell=firstHeaderRow.createCell(0);
yearCell.setCellValue("标题");
workbook.write(out);
out.flush();
out.close();
}
public static void main(String[] args) throws IOException {
String excelPath="d:/test.xls";//excel输出路径
File excel=new File(excelPath);
OutputStream out=new FileOutputStream(excel);
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("标签名");
HSSFRow firstHeaderRow=sheet.createRow(0);// 第一行
sheet.addMergedRegion(new CellRangeAddress(0,0,0,8));
HSSFCell yearCell=firstHeaderRow.createCell(0);
yearCell.setCellValue("标题");
workbook.write(out);
out.flush();
out.close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |