poi的样式设置
来源:互联网 发布:爆破网络连接图 编辑:程序博客网 时间:2024/04/29 07:24
样式设置:
HSSFSheet sheet = workbook.createSheet("sheetName"); //创建sheet
sheet.setVerticallyCenter(true);
//下面样式可作为导出左右分栏的表格模板
sheet.setColumnWidth((short) 0, (short) 2600);// 设置列宽
sheet.setColumnWidth((short) 1, (short) 2400);
sheet.setColumnWidth((short) 2, (short) 2300);
sheet.setColumnWidth((short) 3, (short) 1600);
sheet.setColumnWidth((short) 4, (short) 1800);
sheet.setColumnWidth((short) 5, (short) 1000);// 空列设置小一些
sheet.setColumnWidth((short) 6, (short) 2600);// 设置列宽
sheet.setColumnWidth((short) 7, (short) 2400);
sheet.setColumnWidth((short) 8, (short) 2300);
sheet.setColumnWidth((short) 9, (short) 1600);
sheet.setColumnWidth((short) 10, (short) 1800);
HSSFCellStyle cellstyle = (HSSFCellStyle) workbook.createCellStyle();// 设置表头样式
cellstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 设置居中
HSSFCellStyle headerStyle = (HSSFCellStyle) workbook .createCellStyle();// 创建标题样式
headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //设置垂直居中
headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); //设置水平居中
HSSFFont headerFont = (HSSFFont) workbook.createFont(); //创建字体样式
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 字体加粗
headerFont.setFontName("Times New Roman"); //设置字体类型
headerFont.setFontHeightInPoints((short) 8); //设置字体大小
headerStyle.setFont(headerFont); //为标题样式设置字体样式
HSSFCellStyle headerStyle1 = (HSSFCellStyle) workbook .createCellStyle();// 创建标题样式1
headerStyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
headerStyle1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFFont headerFont1 = (HSSFFont) workbook.createFont();
headerFont1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 字体加粗
headerFont1.setFontName("Times New Roman");
headerFont1.setFontHeightInPoints((short) 8);
headerStyle1.setFont(headerFont1);
HSSFCellStyle headerStyle2 = (HSSFCellStyle) workbook .createCellStyle();// 创建标题样式2
headerStyle2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
headerStyle2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFFont headerFont2 = (HSSFFont) workbook.createFont();
headerFont2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 字体加粗
headerFont2.setFontName("Times New Roman");
headerFont2.setFontHeightInPoints((short) 8);
headerStyle2.setFont(headerFont2);
headerStyle2.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
headerStyle2.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
headerStyle2.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
headerStyle2.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
HSSFCellStyle cell_Style = (HSSFCellStyle) workbook .createCellStyle();// 设置字体样式
cell_Style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell_Style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 垂直对齐居中
cell_Style.setWrapText(true); // 设置为自动换行
HSSFFont cell_Font = (HSSFFont) workbook.createFont();
cell_Font.setFontName("宋体");
cell_Font.setFontHeightInPoints((short) 8);
cell_Style.setFont(cell_Font);
cell_Style.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
cell_Style.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
cell_Style.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
cell_Style.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
HSSFRow row = sheet.createRow((short)1); //创建行
HSSFCell cell = row.createCell((short)1); //创建列
cell.setCellStyle(headerStyle2); //单元格引用样式
HSSFSheet sheet = workbook.createSheet("sheetName"); //创建sheet
sheet.setVerticallyCenter(true);
//下面样式可作为导出左右分栏的表格模板
sheet.setColumnWidth((short) 0, (short) 2600);// 设置列宽
sheet.setColumnWidth((short) 1, (short) 2400);
sheet.setColumnWidth((short) 2, (short) 2300);
sheet.setColumnWidth((short) 3, (short) 1600);
sheet.setColumnWidth((short) 4, (short) 1800);
sheet.setColumnWidth((short) 5, (short) 1000);// 空列设置小一些
sheet.setColumnWidth((short) 6, (short) 2600);// 设置列宽
sheet.setColumnWidth((short) 7, (short) 2400);
sheet.setColumnWidth((short) 8, (short) 2300);
sheet.setColumnWidth((short) 9, (short) 1600);
sheet.setColumnWidth((short) 10, (short) 1800);
HSSFCellStyle cellstyle = (HSSFCellStyle) workbook.createCellStyle();// 设置表头样式
cellstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 设置居中
HSSFCellStyle headerStyle = (HSSFCellStyle) workbook .createCellStyle();// 创建标题样式
headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //设置垂直居中
headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); //设置水平居中
HSSFFont headerFont = (HSSFFont) workbook.createFont(); //创建字体样式
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 字体加粗
headerFont.setFontName("Times New Roman"); //设置字体类型
headerFont.setFontHeightInPoints((short) 8); //设置字体大小
headerStyle.setFont(headerFont); //为标题样式设置字体样式
HSSFCellStyle headerStyle1 = (HSSFCellStyle) workbook .createCellStyle();// 创建标题样式1
headerStyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
headerStyle1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFFont headerFont1 = (HSSFFont) workbook.createFont();
headerFont1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 字体加粗
headerFont1.setFontName("Times New Roman");
headerFont1.setFontHeightInPoints((short) 8);
headerStyle1.setFont(headerFont1);
HSSFCellStyle headerStyle2 = (HSSFCellStyle) workbook .createCellStyle();// 创建标题样式2
headerStyle2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
headerStyle2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFFont headerFont2 = (HSSFFont) workbook.createFont();
headerFont2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 字体加粗
headerFont2.setFontName("Times New Roman");
headerFont2.setFontHeightInPoints((short) 8);
headerStyle2.setFont(headerFont2);
headerStyle2.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
headerStyle2.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
headerStyle2.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
headerStyle2.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
HSSFCellStyle cell_Style = (HSSFCellStyle) workbook .createCellStyle();// 设置字体样式
cell_Style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell_Style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 垂直对齐居中
cell_Style.setWrapText(true); // 设置为自动换行
HSSFFont cell_Font = (HSSFFont) workbook.createFont();
cell_Font.setFontName("宋体");
cell_Font.setFontHeightInPoints((short) 8);
cell_Style.setFont(cell_Font);
cell_Style.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
cell_Style.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
cell_Style.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
cell_Style.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
HSSFRow row = sheet.createRow((short)1); //创建行
HSSFCell cell = row.createCell((short)1); //创建列
cell.setCellStyle(headerStyle2); //单元格引用样式
0 0
- poi的样式设置
- POI操作的一些样式设置
- POI 设置Excel样式
- poi Excel 设置样式
- POI设置单元格样式
- poi Excel 设置样式
- poi Excel 设置样式
- POi设置excel样式
- POI excel 设置样式
- POI设置样式之类
- POI Excel导出样式设置
- poi Excel导出样式设置
- POI Excel导出样式设置
- poi设置execl打印样式
- POI生成Excel常见的几种样式的设置
- POI处理PPT的表格table,XSLFTable样式设置
- java POI设置Excel单元格的边框样式
- poi笔记(2)--设置一些基本的样式
- PostgreSql创建数据库
- Apache和tomcat服务器使用ajp_proxy模块
- 突然发现有人翻译了Android开发的相关开发文档,而且翻译得很好,推荐下
- ajax和xmlHttpRequest
- 在Eclipse中导入SVN库里的Maven项目
- poi的样式设置
- CFRunloop 源码阅读笔记
- JSP+MySql+Servlet实现用户登录
- apppack
- poi导出excel同时合并单元格
- 每天进步一点点——五分钟理解一致性哈希算法(consistent hashing)
- shell wc命令
- mysql学习
- 软件测试工具