| | |
| | | |
| | | |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.CellType; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.net.URLEncoder; |
| | |
| | | // 第四步,创建单元格,并设置值表头 设置表头居中 |
| | | HSSFCellStyle style = wb.createCellStyle(); |
| | | // 创建一个居中格式 |
| | | style.setAlignment((short) 2); |
| | | style.setAlignment(HorizontalAlignment.forInt((short) 2)); |
| | | HSSFCell cell = null; |
| | | // 创建标题 |
| | | for (int i = 0; i < title.length; i++) { |
| | | cell = row.createCell(i); |
| | | cell.setCellType(1); |
| | | cell.setCellType(CellType.forInt(1)); |
| | | cell.setCellValue(title[i]); |
| | | cell.setCellStyle(style); |
| | | } |