KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_reports > ReportBudgetExportExcel


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18  */

19
20 package org.openbravo.erpCommon.ad_reports;
21
22 import org.openbravo.erpCommon.utility.Utility;
23 import org.openbravo.base.secureApp.HttpSecureAppServlet;
24 import org.openbravo.base.secureApp.VariablesSecureApp;
25 import org.openbravo.xmlEngine.XmlDocument;
26 import java.io.*;
27 import javax.servlet.*;
28 import javax.servlet.http.*;
29
30 public class ReportBudgetExportExcel extends HttpSecureAppServlet {
31
32
33   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
34     VariablesSecureApp vars = new VariablesSecureApp(request);
35
36     if (!Utility.hasProcessAccess(this, vars, "", "ReportBudgetGenerateExcel")) {
37       bdError(response, "AccessTableNoView", vars.getLanguage());
38       return;
39     }
40
41     if (vars.commandIn("DEFAULT")){
42       String JavaDoc strKey = vars.getRequiredGlobalVariable("inpcBudgetId", "ReportBudgetGenerateExcel|inpcBudgetId");
43       printPageDataExportExcel(response, vars, strKey);
44     } else pageErrorPopUp(response);
45   }
46
47   void printPageDataExportExcel(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strBudgetId) throws IOException, ServletException {
48
49     if (log4j.isDebugEnabled()) log4j.debug("Output: EXCEL");
50     StringBuffer JavaDoc columns= new StringBuffer JavaDoc();
51     StringBuffer JavaDoc tables= new StringBuffer JavaDoc();
52
53     vars.removeSessionValue("ReportBudgetGenerateExcel|inpTabId");
54
55     response.setContentType("application/xls");
56     PrintWriter out = response.getWriter();
57
58     XmlDocument xmlDocument=null;
59     ReportBudgetGenerateExcelData[] data=null;
60     data = ReportBudgetGenerateExcelData.selectLines(this, vars.getLanguage(), strBudgetId);
61
62     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportBudgetGenerateExcelXLS").createXmlDocument();
63
64
65     xmlDocument.setData("structure1", data);
66     out.println(xmlDocument.print());
67
68   }
69
70   public String JavaDoc getServletInfo() {
71     return "Servlet ReportBudgetGenerateExcel.";
72   } // end of getServletInfo() method
73
}
74
Popular Tags