Wrong parameter values while exporting data from jsp to excel

Ads

 
 
 

Share on Google+Share on Google+

kumari s
Wrong parameter values while exporting data from jsp to excel
1 Answer(s)      5 years and 2 months ago
Posted in : JSP-Servlet

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>
Ads
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

<[email protected] import="java.io.*"%>
<[email protected] import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<[email protected] import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<[email protected] import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<[email protected] 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 ){
}
%>

Ads









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
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
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 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
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 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
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
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
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
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
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
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
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 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
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
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
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
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... the data from database, create an excel file and data insert into newly
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
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
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads