本文實(shí)例為大家分享了java導(dǎo)出包含多個(gè)sheet的excel的具體代碼,供大家參考,具體內(nèi)容如下
要導(dǎo)出多個(gè)sheet,關(guān)鍵就是excel導(dǎo)出的時(shí)間設(shè)定,在執(zhí)行導(dǎo)出文件之前,創(chuàng)建多個(gè)工作表
1
|
hssfsheet sheet = workbook.createsheet(sheettitle); |
這樣每創(chuàng)建一個(gè)工作表,便會(huì)生成一個(gè)新的sheet表,在最后導(dǎo)出excel的時(shí)候一次性導(dǎo)出。
示例:
java類:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
try { hssfworkbook workbook = new hssfworkbook(); outputstream out = response.getoutputstream(); for ( int j= 0 ;j<n;j++){ baseresult<list<t>> teasallist = service.select(teasal); //接下來循環(huán)list放到excel表中 if (teasallist.issuccess()&&teasallist.getresult().size()> 0 ){ //文件標(biāo)題 simpledateformat formatter1 = new simpledateformat( "yyyy-mm-dd" ); string nowdate = formatter1.format( new date()); string java" id="highlighter_950979">
以上所述是小編給大家介紹的java導(dǎo)出包含多個(gè)sheet的excel代碼示例詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)服務(wù)器之家網(wǎng)站的支持! 原文鏈接:https://blog.csdn.net/linyuxb123/article/details/85987682 延伸 · 閱讀
精彩推薦
|