国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

lotus domino EXCEL導出功能開發

2019-11-08 03:17:59
字體:
來源:轉載
供稿:網友

import java.io.PRintWriter;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.text.DecimalFormat;import java.util.Date;import java.util.Vector;import lotus.domino.AgentBase;import lotus.domino.AgentContext;import lotus.domino.Database;import lotus.domino.Document;import lotus.domino.NotesException;import lotus.domino.session;import com.sap.mw.jco.JCO;import net.sf.json.JSONArray;import net.sf.json.JSONObject;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;import java.io.FileOutputStream;     import java.io.OutputStream;    import jxl.Sheet;import jxl.Workbook;import jxl.write.WritableSheet;     import jxl.write.WritableWorkbook; import jxl.write.Label;   public class JavaAgent extends AgentBase {

 public void NotesMain() {

  Session session = null;  AgentContext agentContext = null;  Database db = null;  Document doc = null;  SQLServer_BasicFunction  sqlbf = null;  String dbname = "oerp";  //ResultSet rs = null;  //JCO.Function function = null;        WritableWorkbook wwb;         System.out.println("----------------------kkk");  try {   session = getSession();   agentContext = session.getAgentContext();   db = agentContext.getCurrentDatabase();   doc = agentContext.getDocumentContext();   sqlbf  =  new  SQLServer_BasicFunction(session, db, dbname);   java.text.SimpleDateFormat format1 = new java.text.SimpleDateFormat("yyyyMMddHHmmss");   Date now = new Date();   String dateStr1 = format1.format(now);   String filename=dateStr1 + ".xls";   File directory = new File("");//參數為空       String courseFile = null;   courseFile = directory.getCanonicalPath() ;    String filePath = null;      filePath = courseFile+"//data//domino//html//outputExcel//"+filename;       System.out.println(filePath);      directory=null;

      // 創建Excel工作薄                     // 新建立一個jxl文件,即在e盤下生成testJXL.xls                 OutputStream os = new FileOutputStream(filePath);              wwb=Workbook.createWorkbook(os);                  // 添加第一個工作表并設置第一個Sheet的名字                 WritableSheet sheet = wwb.createSheet("sheet1", 0);       PrintWriter pw = getAgentOutput();   DecimalFormat df2 = new DecimalFormat("####");     StringBuilder sb= new StringBuilder();          // Label(x,y,z) 代表單元格的第x+1列,第y+1行, 內容z                 // 在Label對象的子對象中指明單元格的位置和內容         Label  label = new Label(0,0,"是否錄入到SAP系統");       sheet.addCell(label);      label = new Label(1,0,"物料編號");       sheet.addCell(label);     label = new Label(2,0,"物料描述");       sheet.addCell(label);     label = new Label(3,0,"供應商");      sheet.addCell(label);    label = new Label(4,0,"價格(含稅)");    sheet.addCell(label);    label = new Label(5,0,"舊價格(含稅)");    sheet.addCell(label);    label = new Label(6,0,"新舊價格差異率");    sheet.addCell(label);    label = new Label(7,0,"交貨期");    sheet.addCell(label);    label = new Label(8,0,"稅率");    sheet.addCell(label);    label = new Label(9,0,"材料費");    sheet.addCell(label);    label = new Label(10,0,"加工費");    sheet.addCell(label);    label = new Label(11,0,"是否含運");    sheet.addCell(label);    label = new Label(12,0,"跟最低價的差異率");    sheet.addCell(label);    label = new Label(13,0,"有效期從");    sheet.addCell(label);    label = new Label(14,0,"有效期到");    sheet.addCell(label);    label = new Label(15,0,"條件采購單位");    sheet.addCell(label);       int row =0;   ResultSet rs = null;      System.out.println(doc.getItemValueString("KEYUNID"));   //try   //{          rs=sqlbf.Select("SELECT * FROM WH_SRM_Vendorratio_Sub where  parentid ='"+ doc.getItemValueString("KEYUNID")+"'");        while(rs.next())    {        System.out.println(row);     row =row+1;      label = new Label(0,row,rs.getString("ZConfirm"));     sheet.addCell(label);      label = new Label(1,row,rs.getString("MATNR"));     sheet.addCell(label);      label = new Label(2,row, rs.getString("MAKTX"));     sheet.addCell(label);      label = new Label(3,row, rs.getString("VERDOR"));     sheet.addCell(label);      label = new Label(4,row, rs.getString("PRICE"));     sheet.addCell(label);      label = new Label(5,row, rs.getString("OLDPRICE"));     sheet.addCell(label);     label = new Label(6,row, rs.getString("DIFFPRICE"));     sheet.addCell(label);     label = new Label(7,row, rs.getString("DELIVERYTIME"));     sheet.addCell(label);     label = new Label(8,row, rs.getString("TAXRATE"));     sheet.addCell(label);     label = new Label(9,row, rs.getString("materialcost"));     sheet.addCell(label);     label = new Label(10,row, rs.getString("processcost"));     sheet.addCell(label);     label = new Label(11,row, rs.getString("FREIGHT"));     sheet.addCell(label);     label = new Label(12,row, rs.getString("LowPriceDiff"));     sheet.addCell(label);     label = new Label(13,row, rs.getString("B_VERDERTIME"));     sheet.addCell(label);     label = new Label(14,row, rs.getString("E_VERDERTIME"));     sheet.addCell(label);     label = new Label(15,row, rs.getString("MEINS"));     sheet.addCell(label);        }

         //String PrintPath = "<scr

         // 關閉文件     

         wwb.close();          //pw.println(PrintPath);         pw.println("<script>window.location.href=window.location.href;window.open('/outputexcel/" + filename+"');</script>");   pw.close();        } catch (Exception e) {   e.printStackTrace();  } finally {   try {    //if (rs != null)    // rs.close();    if (doc != null)     doc.recycle();    if (db != null)     db.recycle();    if (agentContext != null)     agentContext.recycle();    if (session != null)     session.recycle();    System.gc();   } catch (NotesException ne) {    ne.printStackTrace();   } catch (Exception e) {    // TODO 自動生成 catch 塊    e.printStackTrace();   }  } }

 }

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邯郸县| 义乌市| 襄垣县| 讷河市| 侯马市| 聂拉木县| 留坝县| 景宁| 图木舒克市| 勐海县| 黄山市| 蕲春县| 平果县| 荥阳市| 彭水| 宁远县| 无锡市| 勃利县| 教育| 鄂温| 尼玛县| 睢宁县| 新安县| 西畴县| 苏州市| 庆安县| 道孚县| 昭通市| 麟游县| 同德县| 措美县| 清镇市| 建瓯市| 砀山县| 开鲁县| 林州市| 西昌市| 腾冲县| 资中县| 普兰县| 松潘县|