① 將Excel導入到資料庫
//Excel導入資料庫
應該先把Excel
使用oledb導入到數據集中.
然後再導入到對應表結構的資料庫中.
② 怎麼將excel表的數據導入資料庫
方法如下:
1、打開要導入的Excel文件,觀察第一列是為欄位還是數據。
2、打開SQLServer,在需要導入的數據點擊右鍵 【任務】-【導入數據】
出現導入導出向導。
3、點擊下一步 ,進入【選擇數據源】頁面,注意紅框設置。
4、點擊下一步 ,進入【選擇目標】頁面,注意紅框設置。
5、點擊下一步 ,進入【指定表復制或查詢】頁面,注意紅框設置。
6、點擊下一步 ,進入【選擇源表和源視圖】頁面,注意紅框設置。
7、下一步,直到完成。出現【執行結果頁面】。
8、最後在SqlServer查詢表。
③ 如何將excel導入到資料庫中
什麼資料庫?如果是mssql資料庫的話
打開企業管理器,展開伺服器-展開資料庫-右鍵點擊那個資料庫名字(想把excel中的數據導入到的資料庫-所有任務-導入數據
然後按照提示一步一步的來,很簡單的
④ 怎麼把excel里的數據導入資料庫中的表中
打開企業管理器,打開要導入數據的資料庫,在表上按右鍵,所有任務-->導入數據,彈出DTS導入/導出向導,按 下一步 , 2、選擇數據源 Microsoft Excel 97-2000,文件名 選擇要導入的xls文件,按 下一步 , 3、選擇目的 用於SQL Server 的Microsoft OLE DB提供程序,伺服器選擇本地(如果是本地資料庫的話,如 VVV),使用SQL Server身份驗證,用戶名sa,密碼為空,資料庫選擇要導入數據的資料庫(如 client),按 下一步 , 4、選擇 用一條查詢指定要傳輸的數據,按 下一步 , 5、按 查詢生成器,在源表列表中,有要導入的xls文件的列,將各列加入到右邊的 選中的列 列表中,這一步一定要注意,加入列的順序一定要與資料庫中欄位定義的順序相同,否則將會出錯,按 下一步 , 6、選擇要對數據進行排列的順序,在這一步中選擇的列就是在查詢語
⑤ 如何將EXCEL表格數據導入資料庫 方法越詳越好 謝謝
進入SQL資料庫的企業管理器中,所有任務——導入數據——選擇數據源為電子表格——以下向導會很清楚。
⑥ 怎樣把excel的數據導入到資料庫裡面去
1 准備Excel導入數據
2 把Excel文件另存為(文本文件(製表符分隔)(*.txt))
3 把新生成的student.txt文件導入到plsql
打開plsql連接到要導入的oracle資料庫再打開Tools --> Text importer... --> Open data file 選擇要導入的txt文件
4 設置導入數據表結構
新生成的表欄位會對應Excel文件第一行標題,但新生成的表欄位Type需要設置,可以設置為nvarchar (導入數據為臨時數據,如果需要可以後期再作類型變換處理)
5 在Data to Oracle Tab中設置導入的表及相應的欄位
⑦ 如何用命令將Excel導入資料庫中
用SQL命令把Excel中的數據導入word中去:
SQL SERVER 和EXCEL的數據導入導出
1、在SQL SERVER里查詢Excel數據:
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
下面是個查詢的示例,它通過用於 Jet 的 OLE DB 提供程序查詢 Excel 電子表格。
SELECT *
FROM OpenDataSource ( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions
2、將Excel的數據導入SQL server :
SELECT * into newtable
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
實例:
SELECT * into newtable
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions
3、將SQL SERVER中查詢到的數據導成一個Excel文件
T-SQL代碼:
EXEC master..xp_cmdshell 'bcp 庫名.dbo.表名out c:\Temp.xls -c -q -S"servername" -U"sa" -P""'
參數:S 是SQL伺服器名;U是用戶;P是密碼
說明:還可以導出文本文件等多種格式
實例:EXEC master..xp_cmdshell 'bcp saletesttmp.dbo.CusAccount out c:\temp1.xls -c -q -S"pmserver" -U"sa" -P"sa"'
EXEC master..xp_cmdshell 'bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout C:\ authors.xls -c -Sservername -Usa -Ppassword'
在VB6中應用ADO導出EXCEL文件代碼:
Dim cn As New ADODB.Connection
cn.open "Driver={SQL Server};Server=WEBSVR;DataBase=WebMis;UID=sa;WD=123;"
cn.execute "master..xp_cmdshell 'bcp "SELECT col1, col2 FROM 庫名.dbo.表名" queryout E:\DT.xls -c -Sservername -Usa -Ppassword'"
4、在SQL SERVER里往Excel插入數據:
insert into OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Temp.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...table1 (A1,A2,A3) values (1,2,3)
T-SQL代碼:
INSERT INTO
OPENDATASOURCE('Microsoft.JET.OLEDB.4.0',
'Extended Properties=Excel 8.0;Data source=C:\training\inventur.xls')...[Filiale1$]
(bestand, prokt) VALUES (20, 'Test')建議樓主可以在淘寶買個excel教程,以備不時之需,推薦店鋪,冬之佳網路科技,我在裡面看過,很全價格低還會不定時更新教程,望採納答案哦
⑧ 怎樣把Excel表格導入到SQL資料庫中
下面是使用Java實現的,將Excel數據表中的數據導入到資料庫里裡面。
public class ReadExcel {
/**
* 對外提供讀取excel 的方法
* */
public static List<List<Object>> readExcel(File file) throws IOException {
String fileName = file.getName();
String extension = fileName.lastIndexOf(".") == -1 ? "" : fileName
.substring(fileName.lastIndexOf(".") + 1);
if ("xls".equals(extension)) {
return read2003Excel(file);
} else if ("xlsx".equals(extension)) {
return read2007Excel(file);
} else {
throw new IOException("不支持的文件類型");
}
}
/**
* 讀取 office 2003 excel
*
* @throws IOException
* @throws FileNotFoundException
*/
private static List<List<Object>> read2003Excel(File file)
throws IOException {
List<List<Object>> list = new LinkedList<List<Object>>();
HSSFWorkbook hwb = new HSSFWorkbook(new FileInputStream(file));
HSSFSheet sheet = hwb.getSheetAt(0);
Object value = null;
HSSFRow row = null;
HSSFCell cell = null;
int counter = 0;
for (int i = sheet.getFirstRowNum(); counter < sheet
.getPhysicalNumberOfRows(); i++) {
row = sheet.getRow(i);
if (row == null) {
continue;
} else {
counter++;
}
List<Object> linked = new LinkedList<Object>();
for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
cell = row.getCell(j);
if (cell == null) {
continue;
}
DecimalFormat df = new DecimalFormat("0");// 格式化 number String
// 字元
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");// 格式化日期字元串
DecimalFormat nf = new DecimalFormat("0.00");// 格式化數字
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_STRING:
// System.out.println(i + "行" + j + " 列 is String type");
value = cell.getStringCellValue();
break;
case XSSFCell.CELL_TYPE_NUMERIC:
/*System.out.println(i + "行" + j
+ " 列 is Number type ; DateFormt:"
+ cell.getCellStyle().getDataFormatString());*/
if ("@".equals(cell.getCellStyle().getDataFormatString())) {
value = df.format(cell.getNumericCellValue());
} else if ("General".equals(cell.getCellStyle()
.getDataFormatString())) {
value = nf.format(cell.getNumericCellValue());
} else {
value = sdf.format(HSSFDateUtil.getJavaDate(cell
.getNumericCellValue()));
}
break;
case XSSFCell.CELL_TYPE_BOOLEAN:
// System.out.println(i + "行" + j + " 列 is Boolean type");
value = cell.getBooleanCellValue();
break;
case XSSFCell.CELL_TYPE_BLANK:
// System.out.println(i + "行" + j + " 列 is Blank type");
value = "";
break;
default:
// System.out.println(i + "行" + j + " 列 is default type");
value = cell.toString();
}
if (value == null || "".equals(value)) {
continue;
}
linked.add(value);
}
list.add(linked);
}
return list;
}
/**
* 讀取Office 2007 excel
* */
private static List<List<Object>> read2007Excel(File file)
throws IOException {
List<List<Object>> list = new LinkedList<List<Object>>();
// 構造 XSSFWorkbook 對象,strPath 傳入文件路徑
XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file));
// 讀取第一章表格內容
XSSFSheet sheet = xwb.getSheetAt(0);
Object value = null;
XSSFRow row = null;
XSSFCell cell = null;
int counter = 0;
for (int i = sheet.getFirstRowNum(); counter < sheet
.getPhysicalNumberOfRows(); i++) {
row = sheet.getRow(i);
if (row == null) {
continue;
} else {
counter++;
}
List<Object> linked = new LinkedList<Object>();
for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
cell = row.getCell(j);
if (cell == null) {
continue;
}
DecimalFormat df = new DecimalFormat("0");// 格式化 number String
// 字元
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");// 格式化日期字元串
DecimalFormat nf = new DecimalFormat("0.00");// 格式化數字
switch (cell.getCellType()) {
case XSSFCell.CELL_TYPE_STRING:
System.out.println(i + "行" + j + " 列 is String type");
value = cell.getStringCellValue();
break;
case XSSFCell.CELL_TYPE_NUMERIC:
/* System.out.println(i + "行" + j
+ " 列 is Number type ; DateFormt:"
+ cell.getCellStyle().getDataFormatString());*/
if ("@".equals(cell.getCellStyle().getDataFormatString())) {
value = df.format(cell.getNumericCellValue());
} else if ("General".equals(cell.getCellStyle()
.getDataFormatString())) {
value = nf.format(cell.getNumericCellValue());
} else {
value = sdf.format(HSSFDateUtil.getJavaDate(cell
.getNumericCellValue()));
}
break;
case XSSFCell.CELL_TYPE_BOOLEAN:
// System.out.println(i + "行" + j + " 列 is Boolean type");
value = cell.getBooleanCellValue();
break;
case XSSFCell.CELL_TYPE_BLANK:
// System.out.println(i + "行" + j + " 列 is Blank type");
value = "";
break;
default:
// System.out.println(i + "行" + j + " 列 is default type");
value = cell.toString();
}
if (value == null || "".equals(value)) {
continue;
}
linked.add(value);
}
list.add(linked);
}
return list;
}
public static void main(String[] args) {
try {
readExcel(new File("D:\Java\apache-tomcat-8.0.26\webapps\poi\docs\testRead.xls"));
// readExcel(new File("D:\test.xls"));
/*
String docsPath = request.getSession(true).getServletContext()
.getRealPath("docs");
String fileName = "testRead.xls";
String filePath = docsPath;
if (EPlatform.Windows.equals(OSinfo.getOSname())) {
filePath = filePath + "\" + fileName;
} else {
filePath = filePath + "/" + fileName;
}
filePath = "E:\testRead.xls";
List<List<Object>> list = readExcel(new File(filePath));
request.setAttribute("list", list);
RequestDispatcher dispatcher = request
.getRequestDispatcher("/read.jsp");
dispatcher.forward(request, response);
*/
} catch (IOException e) {
e.printStackTrace();
}
}
}
⑨ 怎麼將excel中的數據導入資料庫
方法如下:
1、打開要導入的Excel文件,觀察第一列是為欄位還是數據。