tojava
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
17 Posts :: 6 Stories :: 55 Comments :: 0 Trackbacks
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(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
很好的一個
web dev
Apache Http doc(chinese)
ApacheManual (chinese)
搜索
最新評論
1.?re: DOM4J 修改 xml 文件[未登錄]
相當不錯啊,謝謝
--過客
2.?re: DOM4J 修改 xml 文件
Thank you very much
--Hello,Jack
3.?re: DOM4J 修改 xml 文件[未登錄]
用上了
--hhh
4.?re: DOM4J 修改 xml 文件
太感謝你了,你的實例對我很有用,我也用上了。
--飄過
5.?re: webshpere 5.1 增加本地OS 安全性
評論內(nèi)容較長,點擊標題查看
--l like life i like java
閱讀排行榜
1.?DOM4J 修改 xml 文件(6267)
2.?websphere5.1 配置集群(水平)(1187)
3.?webshpere 5.1 增加本地OS 安全性(1097)
4.?ORACE DD(733)
5.?編譯COMPIERE253A in Eclipse sdk 3.1.1(637)
評論排行榜
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?編號='"+rs.getCell(0,?i).getContents().trim()+"'");
????????????????????
//
if(rset.next()){
????????????????????????
//
st.executeUpdate("delete?standarditem?where?編號='"+rs.getCell(0,?i).getContents().trim()+"'");
????????????????????????
????????????????????????
//
st.executeUpdate("update?standarditem?set?品名='"+rset.getString("品名").replace(excel.Constrants.dot,?'?')+"'");
????????????????????
//
????a++;
????????????????????????
//
System.out.println("delete?standarditem?where?編號='"+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
閱讀(181)
評論(0)
編輯
收藏
所屬分類:
web dev
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導航:
博客園
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
主站蜘蛛池模板:
临泉县
|
保德县
|
兴义市
|
霍城县
|
三穗县
|
石柱
|
安徽省
|
辰溪县
|
青岛市
|
中山市
|
安阳县
|
肇庆市
|
利辛县
|
连江县
|
阿拉尔市
|
吉木乃县
|
紫金县
|
太康县
|
枞阳县
|
罗城
|
湘潭县
|
虹口区
|
旺苍县
|
涿州市
|
建瓯市
|
常德市
|
霍城县
|
顺平县
|
南昌市
|
莱阳市
|
保靖县
|
武鸣县
|
怀集县
|
郧西县
|
西林县
|
灵山县
|
枣阳市
|
全南县
|
青岛市
|
孝义市
|
乌兰县
|