Execl匯入notes JAVA代理
import lotus.domino.*;
import java.io.*;
import java.util.Vector;
import jxl.*;
/*******************************************************************************
* @saveSQMessageToOracle
* @作者:徐華祥
* @2009年10月28日
* @說明:Execl檔案的匯入
******************************************************************************/
public class inputExecl_new extends AgentBase {
public void NotesMain() {
System.out.println("代理開始");
EmbeddedObject ebd = null;
String srcFile = "";
InputStream is = null;
Workbook wb = null;
Sheet st = null;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Document currentDoc = agentContext.getDocumentContext();
Database currentDB = agentContext.getCurrentDatabase();
Database wjkhDB = session.getDatabase(currentDB.getServer(),
"whcg/linkey_weijkh.nsf");
String path = currentDoc.getItemValueString("Path");
View wjkhView = wjkhDB.getView("showtousNo");
Vector vtr = session.evaluate("@AttachmentNames", currentDoc);
srcFile = new String("" + vtr.get(0).toString());
ebd = currentDoc.getAttachment(srcFile);
ebd.extractFile(srcFile);
is = new FileInputStream(srcFile);
wb = Workbook.getWorkbook(is);
if (ebd == null) {
wb.close();
wb = null;
return;
}
if (ebd.getType() != EmbeddedObject.EMBED_ATTACHMENT) {
wb.close();
wb = null;
return;
}
st = wb.getSheet(0);
int i = 0;
int m = 0;
int n = 0;
for (i = 1; i < st.getRows(); i++) {
Cell cellno = st.getCell(0, i);
Cell cellqu = st.getCell(7, i);
Document InViewDoc = wjkhView.getDocumentByKey(cellno
.getContents());
if (cellno.getContents().equals("")
|| cellqu.getContents().equals("") || InViewDoc != null) {
m++;
} else if (!cellno.getContents().equals("")
&& !cellqu.getContents().equals("")
&& InViewDoc == null) {
n++;
Document newDoc = wjkhDB.createDocument();
newDoc.appendItemValue("form", "NewDoc");
Cell cell1 = st.getCell(0, i);
if (!cell1.getContents().equals("")) {
newDoc.appendItemValue("tousNo", cell1.getContents());
} else {
newDoc.appendItemValue("tousNo", "");
}
Cell cell2 = st.getCell(1, i);
if (!cell2.getContents().equals("")) {
newDoc.appendItemValue("jiejType", cell2.getContents());
} else {
newDoc.appendItemValue("jiejType", "");
}
Cell cell3 = st.getCell(2, i);
if (!cell3.getContents().equals("")) {
newDoc.appendItemValue("tousTypeName", cell3
.getContents());
} else {
newDoc.appendItemValue("tousTypeName", "");
}
Cell cell4 = st.getCell(3, i);
if (!cell4.getContents().equals("")) {
newDoc.appendItemValue("tousUser", cell4.getContents());
} else {
newDoc.appendItemValue("tousUser", "");
}
Cell cell5 = st.getCell(4, i);
if (!cell5.getContents().equals("")) {
newDoc.appendItemValue("userSex", cell5.getContents());
} else {
newDoc.appendItemValue("userSex", "");
}
Cell cell6 = st.getCell(5, i);
if (!cell6.getContents().equals("")) {
newDoc.appendItemValue("fankTel", cell6.getContents());
} else {
newDoc.appendItemValue("fankTel", "");
}
Cell cell7 = st.getCell(6, i);
if (!cell7.getContents().equals("")) {
newDoc
.appendItemValue("youxjType", cell7
.getContents());
} else {
newDoc.appendItemValue("youxjType", "");
}
Cell cell8 = st.getCell(7, i);
if (!cell8.getContents().equals("")) {
newDoc.appendItemValue("chengqName", cell8
.getContents());
} else {
newDoc.appendItemValue("chengqName", "");
}
Cell cell9 = st.getCell(8, i);
if (!cell9.getContents().equals("")) {
newDoc.appendItemValue("luName", cell9.getContents());
} else {
newDoc.appendItemValue("luName", "");
}
Cell cell10 = st.getCell(9, i);
if (!cell10.getContents().equals("")) {
newDoc.appendItemValue("tousContent", cell10
.getContents());
} else {
newDoc.appendItemValue("tousContent", "");
}
Cell cell11 = st.getCell(10, i);
if (!cell11.getContents().equals("")) {
newDoc.appendItemValue("tousInTel", cell11
.getContents());
} else {
newDoc.appendItemValue("tousInTel", "");
}
Cell cell12 = st.getCell(11, i);
if (!cell12.getContents().equals("")) {
newDoc
.appendItemValue("comyName", cell12
.getContents());
} else {
newDoc.appendItemValue("comyName", "");
}
Cell cell13 = st.getCell(12, i);
if (!cell13.getContents().equals("")) {
newDoc
.appendItemValue("jiejUser", cell13
.getContents());
} else {
newDoc.appendItemValue("jiejUser", "");
}
Cell cell14 = st.getCell(13, i);
if (!cell14.getContents().equals("")) {
newDoc.appendItemValue("zhuanjUser", cell14
.getContents());
} else {
newDoc.appendItemValue("zhuanjUser", "");
}
Cell cell15 = st.getCell(14, i);
if (!cell15.getContents().equals("")) {
newDoc.appendItemValue("jilTime", cell15.getContents());
} else {
newDoc.appendItemValue("jilTime", "");
}
Cell cell16 = st.getCell(15, i);
if (!cell16.getContents().equals("")) {
newDoc.appendItemValue("chujzt", cell16.getContents());
} else {
newDoc.appendItemValue("chujzt", "");
}
newDoc.save(true, true);
}
}
wb.close();
is.close();
String tips = "您有" + m + "條資訊匯入失敗,請檢查投訴編號是否重複或為空,城區名稱是否為空!";
PrintWriter out = getAgentOutput();
if (m == 0) {
out
.println("<meta http-equiv=/"Content-Type/" content=/"text/html; charset=GBK/">");
out
.println("<script language='javascript'>alert('檔案匯入完畢');</script>");
}
if (m != 0) {
out
.println("<meta http-equiv=/"Content-Type/" content=/"text/html; charset=GBK/">");
out.println("<script language='javascript'>alert('" + tips
+ "');</script>");
out
.println("<script language='javascript'>window.location.href='/"
+ path
+ "/showKhjlbother?openform&page=1'</script>");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
相關文章
- ASP.NET利用NPOI元件快速匯入匯出Execl資料ASP.NET元件
- 利用NPOI匯出資料到Execl
- Execl(2003)資料 匯入 SQL Server(2005)SQLServer
- 【Python】Django web頁面匯出execl檔案PythonDjangoWeb
- Excel匯入匯出神器(Java)ExcelJava
- MongoDB日常運維-07遠端匯出資料到execlMongoDB運維
- mysql匯入報錯Variable 'sql_notes' can't be set to the value of 'NULL'MySqlNull
- 轉java操作excel匯入匯出JavaExcel
- Java靜態匯入Java
- java讀取Excel匯入匯出工具JavaExcel
- java 匯入匯出Excel工具類ExcelUtilJavaExcel
- Thinking in java notesThinkingJava
- java怎麼匯入專案?java已有專案如何匯入eclipse?JavaEclipse
- java 匯入到EXCEL表格JavaExcel
- Java之POI操作Excel表-匯入匯出JavaExcel
- Java進行excel的匯入匯出操作JavaExcel
- 關於java中Excel的匯入匯出JavaExcel
- Sql 操作 ExeclSQL
- Java POI匯入Excel檔案JavaExcel
- java使使用者EasyExcel匯入匯出excelJavaExcel
- Java中的匯入匯出(自身驗證版)Java
- Python Execl模組Python
- 【匯出匯入】匯出匯入 大物件物件
- java 從EXCEL匯入到系統JavaExcel
- 【java web】--ojdbc匯入xml資料JavaWebJDBCXML
- 【匯入匯出】sqlldr 匯入案例SQL
- Myeclipse的使用方法-匯入、匯出Java 專案EclipseJava
- java spring mvc jsp excel 匯入JavaSpringMVCJSExcel
- java 從EXCEL匯入到資料庫JavaExcel資料庫
- Java之POI操作,封裝ExcelUtil實現Excel匯入匯出Java封裝Excel
- 利用Java進行MySql資料庫的匯入和匯出JavaMySql資料庫
- 【JAVA】代理模式之Java動態代理Java模式
- 【匯入匯出】Oracle 常用匯入匯出工具集錦Oracle
- 【匯出匯入】% 在匯入匯出中的應用。
- 由淺入深完全理解Java動態代理Java
- Activity 流程模型匯入匯出-activity流程模型匯入匯出模型
- Mysql匯入&匯出MySql
- Mysql匯入匯出MySql