发布网友 发布时间:2022-05-23 04:39
共1个回答
热心网友 时间:2023-10-13 10:01
什么叫小面的excel?我说说步骤吧。追答OutputStream outputStream = response.getOutputStream();
// 创建 一个excel文档对象
HSSFWorkbook workBook = new HSSFWorkbook();
HSSFSheet sheet = null;
// 创建一个工作薄对象
sheet = workBook.createSheet("sheet1");
// 行对象
Row row = null;
// 行索引
int rowIndex = 0;
row = sheet.createRow(rowIndex);
// 样式(左对齐)
CellStyle rightStyle = workBook.createCellStyle();
rightStyle.setAlignment(CellStyle.ALIGN_RIGHT);
// 单元格
int cellIndex = 0;
Cell firstCell = row.createCell(cellIndex);
firstCell.setCellType(Cell.CELL_TYPE_STRING);
firstCell.setCellValue("序号");
firstCell.setCellStyle(rightStyle);
sheet.setColumnWidth(1, 1000);
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=XXX表.xls");