㈠ java 怎麼從excel文件導入到oracle資料庫中
java操作excel一般都使用poi來完成:
1、下載poi相關jar,maven的集成如下:(把${poi.version}替換成你要的版本)
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
<scope>provided</scope>
</dependency>
2、根據poi相關api讀取sheet、row、cell,獲得excel的數據:
封裝row的對象,即每一行數據為一個對象,每個cell為對象里的一個屬性,
整個sheet的數據裝進集合里;
3、處理數據,可以對數據進行驗證或其他操作;
4、寫資料庫操作。
㈡ 在JAVA web開發中怎麼把Excel中的數據導入到oracle資料庫中
1.准備數據:在excel中構造出需要的數據
2.將excel中的數據另存為文本文件(有製表符分隔的)
3.將新保存到文本文件中的數據導入到pl*sql中
在pl*sql中選擇tools--text importer,在出現的窗口中選擇Data from Textfile,然後再選擇Open data file,
在彈出的文件選擇框中選中保存有數據的文本文件,此時將會看到data from textfile中顯示將要導入的數據
4.在configuration中進行如下配置
注:如果不將Name in header勾選上會導致欄位名也當做記錄被導入到資料庫中,從而導致數據錯誤
5.點擊data to oracle,選擇將要導入數據的表,並在fields中將文本中的欄位與表中的欄位進行關聯
6.點擊import按鈕進行導入
7.查看導入的數據
OK,至此數據導入成功。