首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

jexcelapi 的运用

2012-06-26 
jexcelapi 的使用result namedayExcel typestreamparam namecontentTypeapplication/vnd.ms-

jexcelapi 的使用

<result name="dayExcel" type="stream"><param name="contentType">application/vnd.ms-excel</param><param name="contentDisposition">filename="export.xls"</param><param name="bufferSize">1024</param></result>

?

InputStream is;public String execute() {Label label;WritableWorkbook workbook;ByteArrayOutputStream os = new ByteArrayOutputStream();try {workbook = Workbook.createWorkbook(os);WritableSheet sheet = workbook.createSheet("Sheet1", 0);label = new jxl.write.Label(0, 0, "Time/Hour");sheet.addCell(label);for (int i = 0; i < 24; i++) {if (i < 10) {label = new jxl.write.Label(0, i+1, "0" + i);sheet.addCell(label);} else {label = new jxl.write.Label(0, i+1, String.valueOf(i));sheet.addCell(label);}}workbook.write();workbook.close();} catch (Exception e) {e.printStackTrace();}is = new ByteArrayInputStream(os.toByteArray());return "excel";}public InputStream getIs() {return is;}public void setIs(InputStream is) {this.is = is;}public InputStream getInputStream() throws Exception {return is;}

?

热点排行