java实现把excel数据导入到ORACLE中,求全部代码。。。 10
把excel中的数据全部导入到Oracle中,求全部代码,java实现jsp什么的都行,用到servlet里面的配置等,3QQQQQQ...
把excel中的数据全部导入到Oracle中,求全部代码,java实现jsp什么的都行,用到servlet里面的配置等,3QQQQQQ
展开
4个回答
展开全部
你直接用excel的VBA好不好,简单方便,老少皆宜。
如果你非要用java的话你得先找到java处理excel的包导到java工程里。
其余跟正常java存数据一样了。
我给你个VBA连接数据库的代码 你看着改改。
'****ConnectDB*****
Private Function connect(dbusr As String) As Boolean
connect = False
On Error GoTo ERROR_SECTION
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
'******** User Password link ********
Dim dbLink As String
dbLink = dbusr + "/" + dbusr
Set OraDatabase = OraSession.OpenDatabase("orclprod", dbLink, 8&)
'******** User Password link ********
connect = True
Exit Function
ERROR_SECTION:
Call MsgBox(Str(Err.Number) + "-" + Err.Description, vbOKOnly + vbCritical, "Connect Err")
Err.Clear
End Function
'****disConnectDB*****
Private Function disconnect() As Boolean
disconnect = False
On Error GoTo ERROR_SECTION
Set OraDatabase = Nothing
Set OraSession = Nothing
disconnect = True
Exit Function
ERROR_SECTION:
Call MsgBox(Str(Err.Number) + "-" + Err.Description, vbOKOnly + vbCritical, "DisConnect Err")
Err.Clear
End Function
Private Sub CommandButton1_Click()
Dim userDB As String
Dim nameDB As String
Dim nameAccount As String
Dim sumAcc As String
Dim columnRow As Integer
Dim endFal As Boolean
userDB = "aa"
nameDB = "bb"
sumAcc = 4
endFal = True
While endFal
nameAccount = Sheets("AccountCode").Cells(sumAcc, 4)
sumAcc = sumAcc + 1
If nameAccount = "" Then
endFal = False
End If
Wend
If connect(userDB) = False Then
Sheets("AccountCode").Cells(1, 5) = "Connect Error"
Else
For columnRow = 4 To sumAcc - 2
nameAccount = Sheets("AccountCode").Cells(columnRow, 4)
Call getAccountBK(nameDB, nameAccount, columnRow)
Next columnRow
End If
If disconnect = False Then Exit Sub
End Sub
如果你非要用java的话你得先找到java处理excel的包导到java工程里。
其余跟正常java存数据一样了。
我给你个VBA连接数据库的代码 你看着改改。
'****ConnectDB*****
Private Function connect(dbusr As String) As Boolean
connect = False
On Error GoTo ERROR_SECTION
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
'******** User Password link ********
Dim dbLink As String
dbLink = dbusr + "/" + dbusr
Set OraDatabase = OraSession.OpenDatabase("orclprod", dbLink, 8&)
'******** User Password link ********
connect = True
Exit Function
ERROR_SECTION:
Call MsgBox(Str(Err.Number) + "-" + Err.Description, vbOKOnly + vbCritical, "Connect Err")
Err.Clear
End Function
'****disConnectDB*****
Private Function disconnect() As Boolean
disconnect = False
On Error GoTo ERROR_SECTION
Set OraDatabase = Nothing
Set OraSession = Nothing
disconnect = True
Exit Function
ERROR_SECTION:
Call MsgBox(Str(Err.Number) + "-" + Err.Description, vbOKOnly + vbCritical, "DisConnect Err")
Err.Clear
End Function
Private Sub CommandButton1_Click()
Dim userDB As String
Dim nameDB As String
Dim nameAccount As String
Dim sumAcc As String
Dim columnRow As Integer
Dim endFal As Boolean
userDB = "aa"
nameDB = "bb"
sumAcc = 4
endFal = True
While endFal
nameAccount = Sheets("AccountCode").Cells(sumAcc, 4)
sumAcc = sumAcc + 1
If nameAccount = "" Then
endFal = False
End If
Wend
If connect(userDB) = False Then
Sheets("AccountCode").Cells(1, 5) = "Connect Error"
Else
For columnRow = 4 To sumAcc - 2
nameAccount = Sheets("AccountCode").Cells(columnRow, 4)
Call getAccountBK(nameDB, nameAccount, columnRow)
Next columnRow
End If
If disconnect = False Then Exit Sub
End Sub
展开全部
新手也不至于 连java的 Demo都看不懂吧
你可以用poi 这个我测试过 还比较不错 demo也简单 支持 2003 2007
你可以用poi 这个我测试过 还比较不错 demo也简单 支持 2003 2007
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用jxl
更多追问追答
追问
关键不会呀
追答
网上例子一大堆,自己动手丰衣足食呗
book= Workbook.getWorkbook(new File("xls文件路径"));
开始循环sheets book.getSheet
循环行rows sheet.getRows()
然后是单元格 Cell[] = sheet.getRow
取单元格内容 cells[].getContents
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-04-20
展开全部
分呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |