欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

將Oracle數(shù)據(jù)庫(kù)中的數(shù)據(jù)寫入Excel

 更新時(shí)間:2016年12月23日 09:43:01   作者:一個(gè)弱者想變強(qiáng)  
本文主要分享了將Oracle數(shù)據(jù)庫(kù)中的數(shù)據(jù)寫入Excel的關(guān)鍵代碼。具有很好的參考價(jià)值,需要的朋友一起來(lái)看下吧

1.準(zhǔn)備工作

Oracle數(shù)據(jù)庫(kù)“TBYZB_FIELD_PRESSURE”表中數(shù)據(jù)如圖:

Excel模板(201512.xls):

2.任務(wù)說(shuō)明

我們要完成的任務(wù)就是將表“TBYZB_FIELD_PRESSURE”中的數(shù)據(jù),按照Excel模板(201512.xls)的樣式導(dǎo)入到一個(gè)新的Excel中。即:Excel模板(201512.xls)不改變,生成一個(gè)和它一樣的Excel并且導(dǎo)入數(shù)據(jù)。

3.關(guān)鍵代碼

// 使用FieldPressEntity中的每一個(gè)entity,一個(gè)entity包含了所有屬性
 public void insertintoExcel(String yyyy, String mm) throws Exception {
  List<FieldPressEntity> result = tyFieldPressDao.search(yyyy, mm);
  // 讀取Excel的模板
  HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(new File(
    "D:/201512.xls")));
  HSSFSheet sheet = null;
  // 讀取sheet的模板
  sheet = workbook.getSheetAt(0);
  // 定義行
  HSSFRow row;
  // 定義單元格
  HSSFCell cell;
  // for循環(huán),循環(huán)目標(biāo)為行循環(huán)
  for (int i = 0; i < result.size(); i++) {
   System.out.println(result.size());
   // 給e循環(huán)賦值
   FieldPressEntity e = result.get(i);
   // 循環(huán)行
   row = sheet.getRow(3 + i);
   // 給行內(nèi)的單元格賦值
   cell = row.getCell(1);
   cell.setCellValue(e.getH17());
   System.out.println(i + "i內(nèi)+" + e.getH17());
   cell = row.getCell(2);
   cell.setCellValue(e.getH18());
   System.out.println(i + "i內(nèi)+" + e.getH18());
   cell = row.getCell(3);
   cell.setCellValue(e.getH19());
   System.out.println(i + "i內(nèi)+" + e.getH19());
   cell = row.getCell(4);
   cell.setCellValue(e.getH20());
   System.out.println(i + "i內(nèi)+" + e.getH20());
   cell = row.getCell(5);
   cell.setCellValue(e.getH21());
   System.out.println(i + "i內(nèi)+" + e.getH21());
   cell = row.getCell(6);
   cell.setCellValue(e.getH22());
   System.out.println(i + "i內(nèi)+" + e.getH22());
   cell = row.getCell(7);
   cell.setCellValue(e.getH23());
   System.out.println(i + "i內(nèi)+" + e.getH23());
   cell = row.getCell(8);
   cell.setCellValue(e.getH00());
   System.out.println(i + "i內(nèi)+" + e.getH00());
   cell = row.getCell(9);
   cell.setCellValue(e.getH01());
   System.out.println(i + "i內(nèi)+" + e.getH01());
   cell = row.getCell(10);
   cell.setCellValue(e.getH02());
   System.out.println(i + "i內(nèi)+" + e.getH02());
   cell = row.getCell(11);
   cell.setCellValue(e.getH03());
   System.out.println(i + "i內(nèi)+" + e.getH03());
   cell = row.getCell(12);
   cell.setCellValue(e.getH04());
   System.out.println(i + "i內(nèi)+" + e.getH04());
   cell = row.getCell(13);
   cell.setCellValue(e.getH05());
   System.out.println(i + "i內(nèi)+" + e.getH05());
   cell = row.getCell(14);
   cell.setCellValue(e.getH06());
   System.out.println(i + "i內(nèi)+" + e.getH06());
   cell = row.getCell(15);
   cell.setCellValue(e.getH07());
   System.out.println(i + "i內(nèi)+" + e.getH07());
   cell = row.getCell(16);
   cell.setCellValue(e.getH08());
   System.out.println(i + "i內(nèi)+" + e.getH08());
   cell = row.getCell(17);
   cell.setCellValue(e.getH09());
   System.out.println(i + "i內(nèi)+" + e.getH09());
   cell = row.getCell(18);
   cell.setCellValue(e.getH10());
   System.out.println(i + "i內(nèi)+" + e.getH10());
   cell = row.getCell(19);
   cell.setCellValue(e.getH11());
   System.out.println(i + "i內(nèi)+" + e.getH11());
   cell = row.getCell(20);
   cell.setCellValue(e.getH12());
   System.out.println(i + "i內(nèi)+" + e.getH12());
   cell = row.getCell(21);
   cell.setCellValue(e.getH13());
   System.out.println(i + "i內(nèi)+" + e.getH13());
   cell = row.getCell(22);
   cell.setCellValue(e.getH14());
   System.out.println(i + "i內(nèi)+" + e.getH14());
   cell = row.getCell(23);
   cell.setCellValue(e.getH15());
   System.out.println(i + "i內(nèi)+" + e.getH15());
   cell = row.getCell(24);
   cell.setCellValue(e.getH16());
   System.out.println(i + "i內(nèi)+" + e.getH16());
   cell = row.getCell(25);
   cell.setCellValue(e.getDaily_sum());
   System.out.println(i + "i內(nèi)+" + e.getDaily_sum());
   cell = row.getCell(26);
   cell.setCellValue(e.getDaily_avg());
   System.out.println(i + "i內(nèi)+" + e.getDaily_avg());
   cell = row.getCell(27);
   cell.setCellValue(e.getDaily_max());
   System.out.println(i + "i內(nèi)+" + e.getDaily_max());
   cell = row.getCell(28);
   cell.setCellValue(e.getDaily_min());
   System.out.println(i + "i內(nèi)+" + e.getDaily_min());
  }
  // 寫入一個(gè)新的Excel表內(nèi)
  FileOutputStream out = new FileOutputStream(new File("E:/"+yyyy+mm+".xls"));
  // Excel表寫入完成
  workbook.write(out);
  // Excel表退出
  out.close();
 }

總結(jié):我們這個(gè)項(xiàng)目用的是ssh架構(gòu),如果想使用以上代碼,需要按照ssh的規(guī)范,定義dao action service entity四個(gè)包,如果需要頁(yè)面操作還需要js做頁(yè)面。

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

  • oracle表分區(qū)的概念及操作

    oracle表分區(qū)的概念及操作

    Oracle的表分區(qū)功能通過(guò)改善可管理性、性能和可用性,從而為各式應(yīng)用程序帶來(lái)了極大的好處。這篇文章主要介紹了oracle表分區(qū)的概念及操作,需要的朋友可以參考下
    2021-04-04
  • Oracle復(fù)合索引與空值的索引使用問(wèn)題小結(jié)

    Oracle復(fù)合索引與空值的索引使用問(wèn)題小結(jié)

    最近小編在群里討論sql優(yōu)化的問(wèn)題,今天小編給大家?guī)?lái)了Oracle復(fù)合索引與空值的索引使用問(wèn)題小結(jié),需要的朋友參考下吧
    2018-02-02
  • 安裝oracle11g INS-30131執(zhí)行安裝程序驗(yàn)證所需的初始設(shè)置失敗的解決方法

    安裝oracle11g INS-30131執(zhí)行安裝程序驗(yàn)證所需的初始設(shè)置失敗的解決方法

    這篇文章主要為大家詳細(xì)介紹了安裝oracle11g INS-30131執(zhí)行安裝程序驗(yàn)證所需的初始設(shè)置失敗的解決方法,感興趣的小伙伴們可以參考一下
    2016-07-07
  • 使用oracle修改表字段長(zhǎng)度的步驟

    使用oracle修改表字段長(zhǎng)度的步驟

    這篇文章主要介紹了如何使用oracle修改表字段長(zhǎng)度,本文僅僅簡(jiǎn)單介紹了如何使用oracle修改表字段長(zhǎng)度,而oracle提供了大量能使我們快速便捷地處理數(shù)據(jù)的函數(shù)和方法,需要的朋友可以參考下
    2023-07-07
  • Oracle數(shù)據(jù)表保留一條重復(fù)數(shù)據(jù)簡(jiǎn)單方法

    Oracle數(shù)據(jù)表保留一條重復(fù)數(shù)據(jù)簡(jiǎn)單方法

    最近開(kāi)發(fā)的時(shí)候遇到一個(gè)任務(wù),需要對(duì)重復(fù)的數(shù)據(jù)進(jìn)行篩選,所以下面這篇文章主要給大家介紹了關(guān)于Oracle數(shù)據(jù)表保留一條重復(fù)數(shù)據(jù)的簡(jiǎn)單方法,需要的朋友可以參考下
    2023-11-11
  • ORACLE SQL語(yǔ)句優(yōu)化技術(shù)要點(diǎn)解析

    ORACLE SQL語(yǔ)句優(yōu)化技術(shù)要點(diǎn)解析

    這篇文章主要介紹了ORACLE SQL語(yǔ)句優(yōu)化技術(shù)的相關(guān)內(nèi)容,小編覺(jué)得挺不錯(cuò)的,在這里分享給大家,需要的朋友可以參考下。
    2017-10-10
  • 分享ORACLE SEQUENCE跳號(hào)總結(jié)

    分享ORACLE SEQUENCE跳號(hào)總結(jié)

    在ORACLE數(shù)據(jù)庫(kù)中,序列(SEQUENCE)是使用非常頻繁的一個(gè)數(shù)據(jù)庫(kù)對(duì)象,但是有時(shí)候會(huì)遇到序列(SEQUECNE)跳號(hào)(skip sequence numbers)的情形,那么在哪些情形下會(huì)遇到跳號(hào)呢,下面通過(guò)本文給大家詳解介紹,一起看看吧
    2017-09-09
  • oracle數(shù)據(jù)庫(kù)關(guān)于索引建立及使用的詳細(xì)介紹

    oracle數(shù)據(jù)庫(kù)關(guān)于索引建立及使用的詳細(xì)介紹

    這篇文章主要介紹了oracle數(shù)據(jù)庫(kù)關(guān)于索引建立及使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 巧妙解決Oracle NClob讀寫問(wèn)題(經(jīng)驗(yàn)分享)

    巧妙解決Oracle NClob讀寫問(wèn)題(經(jīng)驗(yàn)分享)

    下面小編就為大家?guī)?lái)一篇巧妙解決Oracle NClob讀寫問(wèn)題(經(jīng)驗(yàn)分享)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-10-10
  • oracle 數(shù)據(jù)庫(kù)隔離級(jí)別學(xué)習(xí)

    oracle 數(shù)據(jù)庫(kù)隔離級(jí)別學(xué)習(xí)

    這篇文章主要介紹了oracle數(shù)據(jù)庫(kù)的隔離級(jí)別相關(guān)的知識(shí),數(shù)據(jù)庫(kù)操作的隔離級(jí)別,有需要的朋友可以參考下
    2014-05-05

最新評(píng)論