简单的 在JSP中创建并下载Excel

需用到开源包 jxl.jar

 

jsp全文

<%@ page language="java" import="java.util.*,java.io.*,jxl.*,jxl.write.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% response.reset(); response.setContentType("application/vnd.ms-excel"); response.addHeader("Content-Disposition", "attachment; filename=/"download.xls/""); OutputStream os = response.getOutputStream(); WritableWorkbook wwb = Workbook.createWorkbook(os); WritableSheet ws = wwb.createSheet("Sheet 1", 0); Label label = new Label(0, 0, "this is a label test"); ws.addCell(label); wwb.write(); wwb.close(); os.close(); response.flushBuffer(); out.clear(); out = pageContext.pushBody(); %>

你可能感兴趣的:(java,jsp,OS,Excel,import)