在Java Web中Excel文件如何使用POI實現導出?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
采用Spring mvc架構:
Controller層代碼如下
@Controller public class StudentExportController{ @Autowired private StudentExportService studentExportService; @RequestMapping(value = "/excel/export") public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws Exception { List<Student> list = new ArrayList<Student>(); list.add(new Student(1000,"zhangsan","20")); list.add(new Student(1001,"lisi","23")); list.add(new Student(1002,"wangwu","25")); HSSFWorkbook wb = studentExportService.export(list); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=student.xls"); OutputStream ouputStream = response.getOutputStream(); wb.write(ouputStream); ouputStream.flush(); ouputStream.close(); } }
新聞標題:在JavaWeb中Excel文件如何使用POI實現導出-創新互聯
本文網址:http://vcdvsql.cn/article40/cedjeo.html
成都網站建設公司_創新互聯,為您提供App設計、定制開發、網站導航、品牌網站設計、網站策劃、虛擬主機
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯