此文章为转载文章,原文地址:http://blog.csdn.net/wenshaoyong/article/details/6952631
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("list");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(0);
cell.setCellValue("中国");
cell = row.createCell(1);
cell.setCellValue("日本");
cell = row.createCell(2);
cell.setCellValue("美国");
row = sheet.createRow(1);
cell = row.createCell(0);
cell.setCellValue("2");
cell = row.createCell(1);
cell.setCellValue("3");
cell = row.createCell(2);
cell.setCellValue("5");
row = sheet.createRow(2);
cell = row.createCell(0);
cell.setCellValue("9");
cell = row.createCell(1);
cell.setCellValue("8");
cell = row.createCell(2);
cell.setCellValue("7");
CellRangeAddress c = CellRangeAddress.valueOf("A1:C3");
sheet.setAutoFilter(c);
wb.write(response.getOutputStream());
response.getOutputStream().flush();
response.getOutputStream().close();