Wrong parameter values while exporting data from jsp to excel

Wrong parameter values while exporting data from jsp to excel

This is a jsp report. When i export the report data to an excel, the parameter values on the html report do not match those in the downloaded spreadsheet, specifically, if the parameter value is ALL, it gets translated to NO in excel.

This is the my jsp code -

<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page errorPage="errorPage.jsp" %>
<%@ page import="com.dab.dabuilderConstants"%>
<jsp:useBean id="paramForm" scope="application" class = "com.dab.dabFormParameter" />
<html>
<%
 dabuilderConstants cConstants = new dabuilderConstants();
%>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <STYLE type="text/css">
   .error{
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: red;
    font-weight: bold;
    text-align: left;
    }

.GG {BACKGROUND-COLOR:#FFFFCC;BORDER:1px solid #96965E;PADDING:5px;MARGIN-TOP:12px;MARGIN-BOTTOM:12px}

  </style>

    <title><%=cConstants.sHrrchyReport%></title>
    <script language="javascript">

      errorMessages = new Array();
      visibleFlag=false;
      i=0;

      function doSubmit(){   



            document.forms[0].submit();

     }     
      function addError(erMsg){
          errorMessages[i++] = erMsg;
        }

        function displayErrors(){
            var allMsgs = '';
            for(var j=0; j<errorMessages.length; j++){
                allMsgs += errorMessages[j];
            }
            document.getElementById("errorBody").style.visibility = 'visible';
            visibleFlag=true;
          document.getElementById("msgs").innerHTML=allMsgs;

        }

        function clearErrors(){
          if(visibleFlag==false){
          document.getElementById("errorBody").style.visibility='hidden';
          }
        }



            </script>

  </head>
  <body onload="javascript:clearErrors();">
  <span id="errorBody">
  <table width=80% border=0 align="center" cellspacing=0 cellpadding=0 class="GG">
  <tr bgcolor="#FFFFCC"><td></td></tr>
  <tr bgcolor="#FFFFCC">
    <td class="error"><span id="msgs"></span></td></tr>
  </table>
  </span>
  <%
    if(paramForm.getErrorMessage()!=null){
    String errs=paramForm.getErrorMessage();
  %>
  <script language="javascript">
    addError('<%=errs%>');
    displayErrors();
  </script>
<%
    }
        paramForm.setErrorMessage(null);
%> 

 <%
String permission=null;


  String path=session.getServletContext().getRealPath("/"); 
  if(request.getSession().getAttribute("eUserName")!=null){
   permission=request.getSession().getAttribute("eUserName")+"";
   paramForm.test(request.getSession().getAttribute("eUserName")+"",request.getSession().getAttribute("ePassword")+"");
   paramForm.loadObjects(request.getParameter("reportName")+"",path);

  }else{

  response.sendRedirect("check.jsp");

  }

%>


    <tr> 
       <td colspan="2"><br><label  title="Granted Functions">Display Granted Functions?� � � � </label>
           <select id="gfns" tabindex="3" property="grantedFns" name="grantedFns">
              <option value="All" selected="selected">All</option>
              <option value="Yes">Yes</option>
              <option value="No">No</option>
           </select> 
           <label  title="Granted Menu">[Yes = Display only form functions granted to menus]� � � � </label>
       </td>     
    </tr> 
    <tr> 
       <td colspan="2"><br><label  title="Query Functions">Display Query Only Functions?� � � </label>
           <select id="qfns" tabindex="3" property="QueryFns" name="QueryFns">
              <option value="All" selected="selected">All</option>
              <option value="Yes">Yes</option>
              <option value="No">No</option>

           </select> 
        <label  title="Query Function"> [Yes = Display only "Query Only" form functions]� � � � </label><br>
       </td>    
    </tr> 
    <tr> 
       <td colspan="2"><br><label  title="Excluded Menus">Display Excluded Menus?� � � </label>
           <select id="exmns" tabindex="3" property="exMenus" name="exMenus">
              <option value="Yes">Yes</option>
              <option value="No">No</option>
              <option value="All" selected="selected">All</option>
           </select> 
       <label  title="Excluded Menus"> [Yes = Display only excluded menus and functions]� � � � </label>
<br>
       </td>    
    </tr> 

    <tr align="right">
    <td>
     <button  onclick="javascript:doSubmit()"> 
    <LABEL>Submit Query</LABEL>
    </button>� � 
    <button type="reset"> 
    <LABEL>Reset</LABEL>
    </button>
 <input type="HIDDEN" id="selectedValue" value="<%=cConstants.sHrrchyReport%>" name="reportName">
  </td>
  </tr>
 </table>
 </div>
 </form>
  </body>
</html>
View Answers

March 16, 2012 at 3:09 PM

1)form.jsp:

<html>
<body>
<form name="userform" method="post" action="excelFile.jsp">
<table>
<tr><td>Enter First Name:</td><td><input type="text" name="firstName"></td></tr>
<tr><td>Enter Last Name:</td><td><input type="text" name="lastName"></td></tr>
<tr><td>Enter User Name:</td><td><input type="text" name="userName"></td></tr>
<tr><td>Enter Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Enter Email ID:</td><td><input type="text" name="email"></td></tr>
<tr><td>Enter DOB:</td><td><input type="text" name="dob"></td></tr>
<tr><td><input type="submit" value="Export to excel"></td></tr>
</table>
</form>
</body>
</html>

2)excelFile.jsp

<%@page import="java.io.*"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%
String value1=request.getParameter("firstName");
String value2=request.getParameter("lastName");
String value3=request.getParameter("userName");
String value4=request.getParameter("address");
String value5=request.getParameter("email");
String value6=request.getParameter("dob");
try{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("First Name");
rowhead.createCell((short) 1).setCellValue("Last Name");
rowhead.createCell((short) 2).setCellValue("User Name");
rowhead.createCell((short) 3).setCellValue("Address");
rowhead.createCell((short) 4).setCellValue("E-mail Id");
rowhead.createCell((short) 5).setCellValue("Date Of Birth");

HSSFRow row = sheet.createRow((short)1);
row.createCell((short)0).setCellValue(value1);
row.createCell((short)1).setCellValue(value2);
row.createCell((short)2).setCellValue(value3);
row.createCell((short)3).setCellValue(value4);
row.createCell((short)4).setCellValue(value5);
row.createCell((short)5).setCellValue(value6);
FileOutputStream fileOut = new FileOutputStream("c:\\File.xls");
wb.write(fileOut);
fileOut.close();
out.println("Data is saved in excel file.");
}catch ( Exception ex ){
}
%>









Related Tutorials/Questions & Answers:
Wrong parameter values while exporting data from jsp to excel
Wrong parameter values while exporting data from jsp to excel   This is a jsp report. When i export the report data to an excel, the parameter..., specifically, if the parameter value is ALL, it gets translated to NO in excel
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my database.. Eg- text1,text2,text3,....,upto text30... i want to export this data
Advertisements
read excel data from jsp - JSP-Servlet
read excel data from jsp  Hi how to read excel file from jsp? Excel file is created manually entered data having many sheets? and read the entire sheet and also edit with jsp? pls suggest me?   Hi Friend, 1
exporting data to excel sheet - JDBC
exporting data to excel sheet  Sir i have already send request about... = con.createStatement(); rs= st.executeQuery("Select * from data"); while(rs.next... query in java swing program,i want to print the result about the query in excel
how to read values from excel sheet and compare with database using jsp
how to read values from excel sheet and compare with database using jsp  hi sir i am arun how to read values from excel sheet and compare with database using jsp coding i.e, if i have 6(assetid,assetname,serialno,cubical
How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp  The user can... clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public url
How to Get The Data from Excel sheet into out jsp page???
How to Get The Data from Excel sheet into out jsp page???  How to Get The Data from excel sheet to out jsp page in webApp
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp   the user can... clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database for scientific research analysis. My team members sends research data in excel file
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file that should go to database which exists. am using SQL Server management studio
Exporting data from mysql to csv file
Exporting data from mysql to csv file  Hi friends.... I want to export the data from mysql to csv file... i am having 30 columns in my database.. Eg... example that retrieves the data from the database and save it into csv file
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
how to get a column values from a excel file after attaching it - JSP-Servlet
how to get a column values from a excel file after attaching it  hi sir, How to get a column values from a excel file after attaching it while... and get a values from that store that value in To input box.Please help me sir
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
jsp data in excel - JSP-Servlet
in jsp using table. and getting this data from servlet which has query and this query data has come from beans and using beans i put it in excel jsp in table...jsp data in excel  i have create jsp page which has button
Passing Parameter Values to another jsp in Query Strings
Passing Parameter Values to another jsp in Query Strings  HI ALL, I m trying to pass a variable value to another JSP using query string... even though some values* stored in the variable loginid. Can any one suggest
getting int values from form and insert it in data base in jsp
getting int values from form and insert it in data base in jsp  how...; Hi, You can get the parameter from the request object: String s...=st.executeUpdate("insert into data(name,age, address) values('"+name+"',"+age
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I... ,matter,file field values but not status and from field i am getting null values and also the file is not uploading the content type in other jsp it is showing
insert values from excel file into database
insert values from excel file into database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel... the following link: Insert values from excel file to database
Reading the Date and time values from excel sheet
Reading the Date and time values from excel sheet  hi guys , iam trying to read excel sheet data using apache poi api .my problem is i cant read the date(dd/mm/yy) and time(hh:mm:ss) values concurrently from two different cells
Insert data in Excel File from Database using JSP
Insert data in Excel File from Database  using JSP ... developed a application to insert data  in excel file from database in JSP. We... will retrieve the data from database, create an excel file and data insert
Parameter passing from jsp page to jsp page - JSP-Servlet
Parameter passing from jsp page to jsp page  Hi I intends to pass the parameters that I received from previous page through query String. I get all parameter in respective string variables. I have to passed the parameters
retrieving of value from excel file - JSP-Servlet
now i want a single content that should take the parameter values from the excel... that excel sheet i.e this matter will take a para meter values from the excel...retrieving of value from excel file  Dear sir, Thanks for sending
retrieving of value from excel file - JSP-Servlet
now i want a single content that should take the parameter values from the excel... that excel sheet i.e this matter will take a para meter values from the excel...retrieving of value from excel file  Dear sir, Thanks for sending
jsp with excel sheet data uploading into database
jsp with excel sheet data uploading into database  how to upload data in excel sheet with jsp into oracle 10g database
Retrieving specific data from excel
Retrieving specific data from excel  Hello everyone, i have written a simple code to retrieve data from excel sheet and working fine, the excel file... first sheet from the workbook HSSFSheet sheet = workbook.getSheetAt(0
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which...://www.roseindia.net/answers/viewqa/JSP-Servlet/28123-write-excel-file-into-the-oracle
export data from database to excel sheet - JDBC
export data from database to excel sheet  I am facing a problem about exporting required data from database table to ms-excel sheet.i mean whenever I...("Data is saved in excel file."); rs.close(); connection.close(); } catch
php import data from excel to mysql
php import data from excel to mysql  php import data from excel to mysql
Exception during parsing a parameter from the form in JSP
Exception during parsing a parameter from the form in JSP  Exception during parsing params from a form? I get parameters from a html form. I parse the integer one in the JSP file, but I get exception. Is there anyway I can get
Function data from web in MS excel
Function data from web in MS excel  Hello, I would like to import data from one webpage to Excel using function Data - From Web. The problem is that this web page has at the end .jsp . When I open it via Excel, click to data
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me??? please reply as soon as possible   1)createPDF.jsp
Dynamic table data to Excel in JSP
Dynamic table data to Excel in JSP   Iam trying to export dynamic data to excel . But it is displaying only static data .Kindly help viewtrial.jsp...; String sSql = "SELECT DISTINCT FinancialYear FROM details ORDER BY FinancialYear
How to get data from Excel sheet - Struts
How to get data from Excel sheet  Hi, I have an excel sheet with some data(including characters and numbers). Now i want read the data from excel sheet and display in console first then later insert this data into database
Get values from JSP pages - JSP-Servlet
Get values from JSP pages  I have welcome.jsp in which it has... to another JSP page?Do you want to use database to add column values or you want... Name, City, State) into into next jsp page. note these are not Text fields
extract data from excel sheet to mysql
extract data from excel sheet to mysql  sir, i want to extract data from excel sheet and save the data in mysql5.0 database in the form of table
Exporting to excel using display tag?
Exporting to excel using display tag?  Hai , I am implementing pagination in struts.It has export to excel option.When I am clicking... to excel option.Please help me on this. Regards, N.Santosh
how to display the data from excel to webpage
how to display the data from excel to webpage  Hi, I need help... search for the value 4024 in a excel file and to display the remaining values... that reads the excel file and store data into table. <%@page import="java.io.*"%>
export data to excel sheet - JSP-Servlet
export data to excel sheet  Hi.. how to export data to excel sheet from jsp? and how to update the excel sheet from jsp? and how to get the data from excel sheet? and how to make calculations in excel sheet like total avg
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web application project in jsp. In webform ,I am displaying database data in html table. So my question is ,I want so save this html format data in pdf/excel format
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp

Ads