tojava
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
17 Posts :: 6 Stories :: 55 Comments :: 0 Trackbacks
常用鏈接
我的隨筆
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(2)
給我留言
查看公開留言
查看私人留言
隨筆分類
(14)
AJAX(2)
atleap 相關(guān)
DB(3)
ERP-COMPIERE(1)
Java(7)
Linux Unix
SAP
seam
軟件周期管理(1)
隨筆檔案
(9)
2008年3月 (1)
2007年12月 (1)
2007年10月 (1)
2007年9月 (1)
2007年7月 (1)
2007年4月 (1)
2006年7月 (1)
2005年12月 (2)
文章分類
(5)
atleap
web dev(5)
文章檔案
(4)
2006年7月 (1)
2005年12月 (1)
2005年11月 (2)
相冊
流程圖
appfuse on
atleap
websphere MQ 文集
有關(guān)atleap 的blog
很好的一個(gè)
web dev
Apache Http doc(chinese)
ApacheManual (chinese)
搜索
最新評(píng)論
1.?re: DOM4J 修改 xml 文件[未登錄]
相當(dāng)不錯(cuò)啊,謝謝
--過客
2.?re: DOM4J 修改 xml 文件
Thank you very much
--Hello,Jack
3.?re: DOM4J 修改 xml 文件[未登錄]
用上了
--hhh
4.?re: DOM4J 修改 xml 文件
太感謝你了,你的實(shí)例對(duì)我很有用,我也用上了。
--飄過
5.?re: webshpere 5.1 增加本地OS 安全性
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--l like life i like java
閱讀排行榜
1.?DOM4J 修改 xml 文件(6287)
2.?websphere5.1 配置集群(水平)(1196)
3.?webshpere 5.1 增加本地OS 安全性(1109)
4.?ORACE DD(740)
5.?編譯COMPIERE253A in Eclipse sdk 3.1.1(642)
評(píng)論排行榜
1.?webshpere 5.1 增加本地OS 安全性(22)
2.?websphere5.1 配置集群(水平)(9)
3.?0727(6)
4.?DOM4J 修改 xml 文件(6)
5.?ajax (2)
read excle with jexcle Api
package
?excel;
import
?java.io.File;
import
?java.io.FileInputStream;
import
?java.io.FileOutputStream;
import
?java.io.FileWriter;
import
?java.io.InputStream;
import
?java.io.OutputStreamWriter;
import
?java.sql.Connection;
import
?java.sql.DriverManager;
import
?java.sql.Statement;
import
?org.apache.log4j.
*
;
import
?jxl.Cell;
import
?jxl.Sheet;
import
?jxl.Workbook;
public
?
class
?ImportItems?
{
????ImportItems()
{
????????String?sqlStr2?
=
?
""
;
????????
????????Sheet?rs
=
null
;
????????
//
Cell?c10=null;
????????
try
{
????????????InputStream?is?
=
?
new
?FileInputStream(excel.Constrants.items_filename);
//
????????????jxl.Workbook?rwb?
=
?Workbook.getWorkbook(is);
????????????rs?
=
?rwb.getSheet(
3
);
//
0,1,2,3
????????????}
catch
?(Exception?e)
{
????????????????e.printStackTrace();
????????????????}
????????????
????????????
int
?rsRows?
=
?rs.getRows();
????????????
int
?a
=
0
;
????????????
try
{????
????????????????Class.forName(
"
com.microsoft.jdbc.sqlserver.SQLServerDriver
"
);
????????????????Connection?con?
=
?DriverManager.getConnection(?excel.Constrants.url,??excel.Constrants.user,??excel.Constrants.password?);
????????????????StringBuffer?strB
=
?
new
?StringBuffer();
????????????????Statement?st?
=
?con.createStatement();
????????????????java.sql.ResultSet?rset
=
null
;
????????????????
for
(
int
?i
=
1
;i
<
rsRows;i
++
)
{
//
文具54-56
????????????????????
????????????????????sqlStr2
=
"
??Insert?into?standarditem?values('
"
+
????????????????????rs.getCell(
2
,?i).getContents().trim()
+
"
','
"
+
????????????????????rs.getCell(
3
,?i).getContents()
+
"
','
"
+
????????????????????rs.getCell(
7
,?i).getContents()
+
"
','
"
+
????????????????????rs.getCell(
4
,?i).getContents().replace(excel.Constrants.dot,?
'
?
'
)
????????????????????.replace(
'
*
'
,?
'
?
'
).replace(
'
-
'
,?
'
?
'
).replace(
'
/
'
,?
'
?
'
).replace(
'
=
'
,?
'
?
'
)
????????????????????.replace(
'
#
'
,?
'
?
'
).replace(
'
"
'
,?
'
?
'
).trim()
+
"
','
"
+
????????????????????rs.getCell(
5
,?i).getContents()
+
"
','
"
+
????????????????????rs.getCell(
6
,?i).getContents()
+
"
',
"
+
????????????????????rs.getCell(
9
,?i).getContents()
+
"
,
"
+
????????????????????getCategoreID(rs.getCell(
0
,?i).getContents().trim())
+
"
,0,'
"
+
????????????????????rs.getCell(
12
,?i).getContents()
+
"
',1,'
"
+
????????????????????rs.getCell(
1
,?i).getContents()
+
"
','
"
+
????????????????????
"
729','
"
+
????????????????????rs.getCell(
8
,?i).getContents()
+
"
')
"
;
????????????????????System.out.println(i
+
sqlStr2);
????????????????????
//
strB.append(sqlStr2).append("\n");
????????????????????
//
rset=st.executeQuery("select?*?from?standarditem?");
//
where?編號(hào)='"+rs.getCell(0,?i).getContents().trim()+"'");
????????????????????
//
if(rset.next()){
????????????????????????
//
st.executeUpdate("delete?standarditem?where?編號(hào)='"+rs.getCell(0,?i).getContents().trim()+"'");
????????????????????????
????????????????????????
//
st.executeUpdate("update?standarditem?set?品名='"+rset.getString("品名").replace(excel.Constrants.dot,?'?')+"'");
????????????????????
//
????a++;
????????????????????????
//
System.out.println("delete?standarditem?where?編號(hào)='"+rs.getCell(0,?i).getContents());
????????????????????
//
}
????????????????????st.executeUpdate(sqlStr2);
????????????????????}
????????????????
//
System.out.println("update?standarditem?set?品名=?replace(品名,''"+excel.Constrants.dot+"'','?')");
????????????????
//
st.executeUpdate("update?standarditem?set?品名=?replace(品名,'"+excel.Constrants.dot+"','?')");
????????????????
//
File?fl=?new?File("c:\\a.txt");
????????????????
//
FileWriter?fw?=new?FileWriter(fl);
????????????????
//
fw.write(strB.toString());
????????????????
//
fw.close();
????????????????System.out.println(a);
????????????????st.close();
????????????????con.close();
?????????????}
catch
(Exception?err)
{
???????????????????err.printStackTrace(System.out);}
?????????????}
????
int
?getCategoreID(String?name)
{
????????
int
?i
=
6
;
????????
if
(
"
紙品
"
.equals(name))??i
=
1
;?
????????
else
?
????????????
if
(
"
藥品
"
.equals(name))?i
=
2
;
????????????
else
?
????????????????
if
(
"
清潔用品
"
.equals(name))i
=
3
;
????????????????
else
?
????????????????????
if
(
"
文具
"
.equals(name))?i
=
4
;?
????????????????????
else
?
????????????????????????
if
(
"
印刷品
"
.equals(name))i
=
5
;??
??????????????????????????????
????????????????????????????????
????????
return
?i;
????????
????}
????
public
?
static
?
void
?main(String[]?args)?
{
?????????????ImportItems?t
=
?
new
?ImportItems();
????}
}
posted on 2006-07-29 15:00
l like life i like java
閱讀(186)
評(píng)論(0)
編輯
收藏
所屬分類:
web dev
新用戶注冊
刷新評(píng)論列表
只有注冊用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
read excle with jexcle Api
在windows2000server上安裝配置Apache+Tomcat (From:Internet)
Powered by:
BlogJava
Copyright © l like life i like java
主站蜘蛛池模板:
鹿邑县
|
青州市
|
墨竹工卡县
|
鄂州市
|
柳州市
|
交口县
|
吐鲁番市
|
玉山县
|
富平县
|
仲巴县
|
辛集市
|
天台县
|
萍乡市
|
柘荣县
|
寿宁县
|
侯马市
|
临汾市
|
乌拉特后旗
|
宜宾县
|
南康市
|
湖州市
|
扎鲁特旗
|
龙井市
|
天台县
|
类乌齐县
|
阳东县
|
辉南县
|
腾冲县
|
十堰市
|
阿瓦提县
|
夏津县
|
和政县
|
永春县
|
韶山市
|
林芝县
|
阿瓦提县
|
延吉市
|
武平县
|
宁阳县
|
洞头县
|
哈尔滨市
|