so.java

so.java

excel读取

import   java.util.ArrayList;
import   remedy.api.WritertoAR;
import   com.remedy.arsys.api.EntryItem;
import   com.remedy.arsys.api.FieldID;
import   com.remedy.arsys.api.Value;

public   class   Common   extends   WritertoAR   {
public   Common()   {
id.add(new   Long(536870913));
}

private   static   final   String   FORMNAME   =   "BOCOM_IF_CENTERFORM ";//   BOCOM_IF_CENTERFORM

private   ArrayList   id   =   new   ArrayList();

private   ArrayList   value   =   new   ArrayList();

public   EntryItem[]   creatEntryItems()   {
//   TODO   Auto-generated   method   stub
EntryItem[]   entryItems   =   new   EntryItem[value.size()];
for   (int   i   =   0;   i   <   entryItems.length;   i++)   {
entryItems[i]   =   new   EntryItem(new   FieldID(Long.parseLong((this.id
.get(i)).toString())),   new   Value(new   String(this.value.get(
i).toString())));
}
return   entryItems;
}

public   String   getFormName()   {
//   TODO   Auto-generated   method   stub
return   FORMNAME;
}

public   ArrayList   getId()   {
return   id;
}

public   void   setId(ArrayList   id)   {
this.id   =   id;
}

public   ArrayList   getValue()   {
return   value;
}

public   void   setValue(ArrayList   value)   {
this.value   =   value;
}
}


****************************************************

public   void   ReadXLS()   {
try   {
String   path2   =   " ";
Workbook   book   =   Workbook.getWorkbook(new   File(path2));
//   获得第一个工作表对象
Sheet   sheet   =   book.getSheet(0);
Cell   cell1   =   null;

for   (int   i   =   1;   i   <   sheet.getRows();   i++)   {
ids   =   new   ArrayList <Long> ();
values   =   new   ArrayList <String> ();
for   (int   j   =   0;   j   <   sheet.getColumns();   j++)   {
if   (j   ==   0)   {
ids.add(new   Long(536870915));
}   else   {
ids.add(new   Long(ids.get(ids.size()   -   1)   +   1));
}
cell1   =   sheet.getCell(j,   i);
String   result   =   cell1.getContents();
values.add(result);
//   System.out.println(ids.get(j));
//   System.out.println(values.get(j));
}
out.setId(ids);
out.setValue(values);
ARSWriter.getArswriter().createEntry(out);
}
book.close();
}   catch   (Exception   ex)   {
ex.printStackTrace();
}

posted on 2008-12-21 22:49 so.java 阅读(206) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

java study

搜索

最新评论

阅读排行榜

评论排行榜