當(dāng)前位置:首頁(yè) > 芯聞號(hào) > 充電吧
[導(dǎo)讀]首先將要導(dǎo)出的數(shù)據(jù)庫(kù)表的數(shù)據(jù)封裝到一個(gè)list集合中,然后循環(huán)遍歷該list集合再應(yīng)用jxl組件將這些數(shù)據(jù)寫(xiě)入excel文件。?001package com.ybhacker.mailbox.util

首先將要導(dǎo)出的數(shù)據(jù)庫(kù)表的數(shù)據(jù)封裝到一個(gè)list集合中,然后循環(huán)遍歷該list集合

再應(yīng)用jxl組件將這些數(shù)據(jù)寫(xiě)入excel文件。

?

001package com.ybhacker.mailbox.util;002?003import java.io.File;004import java.util.List;005?006import jxl.*;007import jxl.format.Alignment;008import jxl.format.Colour;009import jxl.format.UnderlineStyle;010import jxl.format.VerticalAlignment;011import jxl.write.Label;012import jxl.write.WritableFont;013import jxl.write.WritableSheet;014import jxl.write.WritableWorkbook;015?016import com.ybhacker.mailbox.model.BoxList;017?018/**019?* Excel操作020?* 021?* @author Windows7022?* 023?*/024public classExcelOperationUtil {025?026????/**027?????* 保存數(shù)據(jù)內(nèi)容到excel028?????* @param list029?????* @param savepath030?????* @return031?????*/032?033????publicboolean readDataToExcelFile(List034????????try{035????????????WritableWorkbook book = Workbook.createWorkbook(newFile(savepath));036????????????WritableSheet sheet = book.createSheet("SHELL",0);037????????????// 設(shè)置字體樣式038????????????jxl.write.WritableFont font =new jxl.write.WritableFont(039????????????????????WritableFont.ARIAL,15, WritableFont.BOLD, false,040????????????????????UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.GREEN);041????????????jxl.write.WritableCellFormat cellFormat =new jxl.write.WritableCellFormat(042????????????????????font);043????????????cellFormat.setAlignment(Alignment.CENTRE);044????????????cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);// 設(shè)置單元格內(nèi)容兩端對(duì)齊045????????????cellFormat.setBackground(Colour.GRAY_25);// 背景顏色046????????????Label label_title =new Label(0,0, "WEBSHELL收信箱子系統(tǒng)V2.0",047????????????????????cellFormat);048????????????sheet.mergeCells(0,0, 4,0);// 合并第一行的第1個(gè)到第5個(gè)單元格049????????????sheet.setRowView(0,600, false);// 設(shè)置第一行的行高050?051????????????Label label_id =new Label(0,1, "ID");052????????????Label label_url =new Label(1,1, "木馬地址");053????????????Label label_script =new Label(2,1, "腳本類(lèi)型");054????????????Label label_pass =new Label(3,1, "密碼");055????????????Label label_host =new Label(4,1, "域名");056????????????Label label_google =new Label(5,1, "谷歌權(quán)重");057????????????Label label_baidu =new Label(6,1, "百度權(quán)重");058????????????Label label_indexed =new Label(7,1, "收錄總數(shù)");059????????????Label label_createtime =new Label(8,1, "創(chuàng)建時(shí)間");060????????????Label label_sell =new Label(9,1, "是否出售");061?062????????????sheet.setColumnView(4,15);// 設(shè)置列寬063????????????sheet.addCell(label_title);064????????????sheet.addCell(label_id);065????????????sheet.addCell(label_url);066????????????sheet.addCell(label_script);067????????????sheet.addCell(label_pass);068????????????sheet.addCell(label_host);069????????????sheet.addCell(label_google);070????????????sheet.addCell(label_baidu);071????????????sheet.addCell(label_indexed);072????????????sheet.addCell(label_createtime);073????????????sheet.addCell(label_sell);074?075????????????for(int i = 0; i < list.size(); i++) {// 遍歷數(shù)據(jù)對(duì)象的集合,將所有信息導(dǎo)出到Excel076????????????????BoxList temp = (BoxList) list.get(i);077????????????????String script ="未知";078????????????????String createtime = temp.getnCreateTime().toString();079????????????????if(temp.getnScript() == 1) {080????????????????????script ="ASP";081????????????????}082????????????????if(temp.getnScript() == 2) {083????????????????????script ="PHP";084????????????????}085????????????????if(temp.getnScript() == 3) {086????????????????????script ="ASPX";087????????????????}088????????????????if(temp.getnScript() == 4) {089????????????????????script ="JSP";090????????????????}091????????????????String Sell ="正常";092????????????????if(temp.isnSell()) {093????????????????????Sell ="已售";094????????????????}095????????????????Label id_value =new Label(0, i +2, temp.getId() + "");096????????????????Label url_value =new Label(1, i +2, temp.getnUrl());097????????????????Label script_value =new Label(2, i +2, script);098????????????????Label pass_value =new Label(3, i +2, temp.getnPass());099????????????????Label host_value =new Label(4, i +2, temp.getnHost());100????????????????Label google_value =new Label(5, i +2, temp.getnGoogle());101????????????????Label baidu_value =new Label(6, i +2, temp.getnBaidu());102????????????????Label indexed_value =new Label(7, i +2, temp.getnIndexed());103????????????????Label createtime_value =new Label(8, i +2, createtime);104????????????????Label sell_value =new Label(9, i +2, Sell);105?106????????????????sheet.addCell(id_value);107????????????????sheet.addCell(url_value);108????????????????sheet.addCell(script_value);109????????????????sheet.addCell(pass_value);110????????????????sheet.addCell(host_value);111????????????????sheet.addCell(google_value);112????????????????sheet.addCell(baidu_value);113????????????????sheet.addCell(indexed_value);114????????????????sheet.addCell(createtime_value);115????????????????sheet.addCell(sell_value);116?117????????????}118????????????book.write();119????????????book.close();120????????????returntrue;121????????} catch (Exception e) {122????????????System.out.println("異常信息:"+ e.getMessage());123????????????e.printStackTrace();124????????????returnfalse;125????????}126????}127}

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車(chē)的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

倫敦2024年8月29日 /美通社/ -- 英國(guó)汽車(chē)技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車(chē)工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車(chē)。 SODA V工具的開(kāi)發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車(chē) 人工智能 智能驅(qū)動(dòng) BSP

北京2024年8月28日 /美通社/ -- 越來(lái)越多用戶(hù)希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來(lái)越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對(duì)日本游戲市場(chǎng)的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)開(kāi)幕式在貴陽(yáng)舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱(chēng),數(shù)字世界的話語(yǔ)權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對(duì)環(huán)境變化,經(jīng)營(yíng)業(yè)績(jī)穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤(rùn)率延續(xù)升勢(shì) 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長(zhǎng) 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競(jìng)爭(zhēng)力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競(jìng)爭(zhēng)優(yōu)勢(shì)...

關(guān)鍵字: 通信 BSP 電信運(yùn)營(yíng)商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺(tái)與中國(guó)電影電視技術(shù)學(xué)會(huì)聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會(huì)上宣布正式成立。 活動(dòng)現(xiàn)場(chǎng) NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長(zhǎng)三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會(huì)上,軟通動(dòng)力信息技術(shù)(集團(tuán))股份有限公司(以下簡(jiǎn)稱(chēng)"軟通動(dòng)力")與長(zhǎng)三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉