Harshu
jsp-servlet
0 Answer(s)      3 years ago
Posted in : JSP-Servlet

vieworderCD.jsp

<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCellStyle"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFFont"%>
<%@ page import="org.apache.poi.hssf.util.HSSFColor"%>
<%@ page contentType="application/vnd.ms-excel" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%


HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("View Order");
HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)4);
HSSFRow row1 =sheet.createRow((short)3);
HSSFCell cell1 = row1.createCell((short)0);
HSSFCell cell2 = row1.createCell((short)1);
HSSFCell cell3 = row1.createCell((short)2);
HSSFCell cell4= row1.createCell((short)3);
HSSFCell cell5 = row1.createCell((short)4);
HSSFCell cell6 = row1.createCell((short)5);
HSSFCell cell7 = row1.createCell((short)6);
HSSFCell cell8 = row1.createCell((short)7);
HSSFCell cell9 = row1.createCell((short)8);
HSSFCell cell10 = row1.createCell((short)9);
HSSFCell cell11 = row1.createCell((short)10);
HSSFCell cell12 = row1.createCell((short)11);
HSSFCell cell13 = row1.createCell((short)12);
HSSFCell cell14 = row1.createCell((short)13);

HSSFFont font = wb.createFont();
font.setFontHeightInPoints((short)14);
font.setFontName("Arial Black");
font.setItalic(true);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFont(font);
cell.setCellStyle(cellStyle);

HSSFFont font1 = wb.createFont();
font1.setFontHeightInPoints((short)12);
font1.setFontName("Arial Black");
font1.setUnderline((byte)3);
HSSFCellStyle cellStyle1 = wb.createCellStyle();
cellStyle1.setFont(font1);
cellStyle1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell1.setCellStyle(cellStyle1);

HSSFFont font2 = wb.createFont();
font2.setFontHeightInPoints((short)12);
font2.setFontName("Arial Black");
HSSFCellStyle cellStyle2 = wb.createCellStyle();
cellStyle2.setFont(font2);
cellStyle2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell2.setCellStyle(cellStyle2);

HSSFFont font3 = wb.createFont();
font3.setFontHeightInPoints((short)12);
font3.setFontName("Arial Black");
HSSFCellStyle cellStyle3 = wb.createCellStyle();
cellStyle3.setFont(font3);
cellStyle3.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell3.setCellStyle(cellStyle3);

HSSFFont font4 = wb.createFont();
font4.setFontHeightInPoints((short)12);
font4.setFontName("Arial Black");
HSSFCellStyle cellStyle4 = wb.createCellStyle();
cellStyle4.setFont(font4);
cellStyle4.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell4.setCellStyle(cellStyle4);

HSSFFont font5 = wb.createFont();
font5.setFontHeightInPoints((short)12);
font5.setFontName("Arial Black");
HSSFCellStyle cellStyle5 = wb.createCellStyle();
cellStyle5.setFont(font5);
cellStyle5.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell5.setCellStyle(cellStyle5);

HSSFFont font6 = wb.createFont();
font6.setFontHeightInPoints((short)12);
font6.setFontName("Arial Black");
HSSFCellStyle cellStyle6 = wb.createCellStyle();
cellStyle6.setFont(font6);
cellStyle6.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell6.setCellStyle(cellStyle6);

HSSFFont font7 = wb.createFont();
font7.setFontHeightInPoints((short)12);
font7.setFontName("Arial Black");
HSSFCellStyle cellStyle7 = wb.createCellStyle();
cellStyle7.setFont(font7);
cellStyle7.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell7.setCellStyle(cellStyle7);

HSSFFont font8 = wb.createFont();
font8.setFontHeightInPoints((short)12);
font8.setFontName("Arial Black");
HSSFCellStyle cellStyle8 = wb.createCellStyle();
cellStyle8.setFont(font8);
cellStyle8.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell8.setCellStyle(cellStyle8);

HSSFFont font9 = wb.createFont();
font9.setFontHeightInPoints((short)12);
font9.setFontName("Arial Black");
HSSFCellStyle cellStyle9 = wb.createCellStyle();
cellStyle9.setFont(font9);
cellStyle9.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell9.setCellStyle(cellStyle9);

HSSFFont font10 = wb.createFont();
font10.setFontHeightInPoints((short)12);
font10.setFontName("Arial Black");
HSSFCellStyle cellStyle10 = wb.createCellStyle();
cellStyle10.setFont(font10);
cellStyle10.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell10.setCellStyle(cellStyle10);

HSSFFont font11 = wb.createFont();
font11.setFontHeightInPoints((short)12);
font11.setFontName("Arial Black");
HSSFCellStyle cellStyle11 = wb.createCellStyle();
cellStyle11.setFont(font11);
cellStyle11.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell11.setCellStyle(cellStyle11);

HSSFFont font12 = wb.createFont();
font12.setFontHeightInPoints((short)12);
font12.setFontName("Arial Black");
HSSFCellStyle cellStyle12 = wb.createCellStyle();
cellStyle12.setFont(font12);
cellStyle12.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell12.setCellStyle(cellStyle12);

HSSFFont font13 = wb.createFont();
font13.setFontHeightInPoints((short)12);
font13.setFontName("Arial Black");
HSSFCellStyle cellStyle13 = wb.createCellStyle();
cellStyle13.setFont(font13);
cellStyle13.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell13.setCellStyle(cellStyle13);

HSSFFont font14 = wb.createFont();
font14.setFontHeightInPoints((short)12);
font14.setFontName("Arial Black");
HSSFCellStyle cellStyle14 = wb.createCellStyle();
cellStyle14.setFont(font14);
cellStyle14.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cell14.setCellStyle(cellStyle14);

Connection con=null;
Statement stmt=null;
ResultSet rs=null;
int i=Integer.parseInt(request.getParameter("Num"));


//catch ( Exception ex ){}
%>

<%
try {


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Advdsn");
stmt=con.createStatement();
rs=stmt.executeQuery("SELECT OrderTab.OrderNo, OrderTab.Day, OrderTab.Name, ClassifiedDisplay.State, ClassifiedDisplay.City, ClassifiedDisplay.MainCategory, ClassifiedDisplay.imageName, ClassifiedDisplay.SubCategory, ClassifiedDisplay.NewsPaper, ClassifiedDisplay.Size ,ClassifiedDisplay.Color ,ClassifiedDisplay.Page ,ClassifiedDisplay.Total ,ClassifiedDisplay.Day &'/' & ClassifiedDisplay.Month & '/' & ClassifiedDisplay.Year AS DateofAd FROM OrderTab INNER JOIN ClassifiedDisplay ON OrderTab.OrderNo=ClassifiedDisplay.OrderNo WHERE ((OrderTab.OrderNo)="+i+" And (OrderTab.OrderNo)=[ClassifiedDisplay].[OrderNo])");

//rs=stmt.executeQuery("SELECT OrderTab.OrderNo, OrderTab.Day, OrderTab.Name, ClassifiedText.State, ClassifiedText.City, ClassifiedText.MainCategory, ClassifiedText.SubCategory, ClassifiedText.NewsPaper, ClassifiedText.Size ,ClassifiedText.Page ,ClassifiedText.Total , ClassifiedText.Day &'/' & ClassifiedText.Month & '/' & ClassifiedText.Year AS DateofAd FROM OrderTab INNER JOIN ClassifiedText ON OrderTab.OrderNo=ClassifiedText.OrderNo WHERE (((OrderTab.OrderNo)="+i+" And (OrderTab.OrderNo)=[ClassifiedText].[OrderNo]))");
//rs=stmt.executeQuery("select OrderNo,Name,Day from OrderTab where OrderNo="+i+"");


cell.setCellValue("Order No wise Report for Classified Display Ads");
cell1.setCellValue("OrderNo");
cell2.setCellValue("Day");
cell3.setCellValue("Name");
cell4.setCellValue("AdvtDate");
cell5.setCellValue("State");
cell6.setCellValue("City");
cell7.setCellValue("MainCat");
cell8.setCellValue("SubCat");
cell9.setCellValue("Newspaper");
cell10.setCellValue("ImageName");
cell11.setCellValue("Size");
cell12.setCellValue("Color");
cell13.setCellValue("AdPages");
cell14.setCellValue("Total");

while(rs.next())

{
HSSFRow row2 =sheet.createRow((short)4);
row2.createCell((short)0).setCellValue(rs.getInt("OrderNo"));
row2.createCell((short)1).setCellValue(rs.getString("Day"));
row2.createCell((short)2).setCellValue(rs.getString("Name"));
row2.createCell((short)3).setCellValue(rs.getString("DateOfAd"));
row2.createCell((short)4).setCellValue(rs.getString("State"));
row2.createCell((short)5).setCellValue(rs.getString("City"));
row2.createCell((short)6).setCellValue(rs.getString("MainCategory"));
row2.createCell((short)7).setCellValue(rs.getString("SubCategory"));
row2.createCell((short)8).setCellValue(rs.getString("Newspaper"));
row2.createCell((short)9).setCellValue(rs.getString("imageName"));
row2.createCell((short)10).setCellValue(rs.getString("Size"));
row2.createCell((short)11).setCellValue(rs.getString("Color"));
row2.createCell((short)12).setCellValue(rs.getString("Page"));
row2.createCell((short)13).setCellValue(rs.getInt("Total"));

}

FileOutputStream fileOut = new FileOutputStream("C:\\ExcelCD\\ViewOrdCD"+i+".xls");
wb.write(fileOut);
fileOut.close();
//out.println("Your excel file has been generated");
}
catch(Exception e2)
{
out.println(e2.toString());
}
//}



%>

In this code though i have given that it should create file in C:/excel folder then too it asks me to save the file why is this coming i dont know so please help me sir?

and when i give font.setBold(true);
then its giving me error i.e variable not found.
please reply me sir as soon as possible??

Thank you sir.





View Answers









Related Pages:
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
jsp/servlet - JSP-Servlet
jsp/servlet  How to create and save the excel file on given location using jsp/servlet?  hi Geetanjali, Read for more information, http://www.roseindia.net/jsp/poi/excelPOI.shtml Thanks
jsp and servlet
jsp and servlet  what is the difference between jsp and servlet ? what is the advantages and disadvantages of jsp and servlet
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value.   Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/servlet/passParameters.html
JSP & Servlet - JSP-Servlet
JSP & Servlet  Its an IBM Question In the process of login validation. i'm entering the username correct and pass wrong. when using... is wrong ? can any one help me with coding ? i'm just a beginner with JSP
JSP,Servlet - JSP-Servlet
JSP,Servlet  How can i pass a list of objects from jsp to an Action? Please help me to do
jsp/servlet - JSP-Servlet
jsp/servlet  Hello friends ! I want to create columns in a table at run time everyday. I am using mysql database.how should I do it? thanks in advance  Hi friend, Plz explain your problem in details to solve
jsp-servlet - JSP-Servlet
jsp-servlet  what is the problem with using microsoft access as database? The sample example, i got from you is: database:mysql. One of my java faculty said, we cannot use ms-access as database because it has some dis-advantage
jsp-servlet - JSP-Servlet
jsp-servlet  vieworderCD.jsp <% HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("View Order"); HSSFRow row = sheet.createRow((short)0); HSSFCell cell
Jsp-Servlet - JSP-Servlet
Jsp-Servlet  PlaceAd.jsp function Calculate() { var fpval; var cityamt; var newspaper; var sizeval; var city = document.form.city.value; var noofwd = document.form.Count.value
jsp/servlet - JSP-Servlet
jsp/servlet  Hello ! How can we call a servlet on a link on html page like a href="servletname"> Call Servlet Is it possible?   Hi friend, I am sending simple application using servlet. This is form
JSP & Servlet - JSP-Servlet
JSP & Servlet  In the process of login validation. i'm entering the username correct and pass wrong. when using response.sendRedirect() a new req... help me with coding ? i'm just a beginner with JSP and sServlets
JSP - JSP-Servlet
JSP & Servlet Example Code  Need example of JSP & Servlet
jsp and servlet
the data and delete the data,using jsp and servlet...jsp and servlet  I want to create a login form,which have many fields,and have a connectivity with thwe oracle database,and login form will have
JAVA JSP and Servlet - JSP-Servlet
JAVA JSP and Servlet  for sending mail through lan without intenet and also chatting facility for online users using Java JSP & SERVLET code.  Hi Friend, Please visit the following links: http://www.roseindia.net
JSP and Servlet sort - JSP-Servlet
JSP and Servlet sort  Hi I have 3 records in my database. I want to sort them according to their respective headings. Here's the code I have for displaying them in the jsp: Universal Books Home Page
Jsp ,Servlet Problem - JSP-Servlet
Jsp ,Servlet Problem  hi, m new to jsp n Servlet. i really find ur... with oracle. it worked wonders. now i m starting jsp n servlet learning.. pls... to execute a servlet code on tomcat server... Thanking u... Santosh  
Programming - JSP-Servlet
Programming jsp servlet   Couple of examples that can help to start programming jsp servlet
Navigate from jsp to servlet - JSP-Servlet
Navigate from jsp to servlet   Hi Friends, Sample code for Navigating a page from jsp to servlet. Thanks
java - JSP-Servlet
java  why is required to write both jsp and servlet in a application of java
Searching for Code - JSP-Servlet
JSP, Servlet Searching for Code  Hi, i am looking for a jsp servlet code examples for the search function in my application.Thanks
Jsp-Servlet
Jsp-Servlet  how can i display the values in jsp pages as list from servlet ? can you help me out plz ? thanks
jsp servlet
jsp servlet  dispay hindi in jsp
JSP-Servlet
JSP-Servlet  Hi have created a JSP page and I need to print it when the user clicks on the print button. I have put a print button on the JSP page. Can somebody plz help me out with the Servlet page coding
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP with one text field to enter the URL and a submit button.On clicking the submit button, send the request to a servlet .Once the servlet receives the request, it need
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP with one text field to enter the URL and a submit button.On clicking the submit button, send the request to a servlet .Once the servlet receives the request, it need
jsp servlet
code to Create a JSP with one text field to enter the URL and a submit button  i dont know how to write a code to Create a JSP with one text field... the request to a servlet .Once the servlet receives the request, it need to create
jsp servlet
how to write a code to Create a JSP with one text field to enter the URL  i dont know how to write a code to Create a JSP with one text field... to a servlet .Once the servlet receives the request, it need to create a thread
JSP AND SERVLET
JSP AND SERVLET  I want to create a login form with user name and password field,if the user is new then s/he can click on the new user hyperlink and new page will be display,and data will be updated to the database successfully
jsp and servlet
jsp and servlet  If i want to get dynamic value in html textbox or in jsp,then how can I get the value,how the value will be transfered from servlet... javax.servlet.*; import javax.servlet.http.*; public class Servlet extends
JSP-Servlet
JSP-Servlet  Hi , I have a table and a checkbox box in that. If i select a particular checkbox, then the particular row details has to be fetched and should be given to two buttons..i/e. when i click on a checkbox, two buttons
jsp and servlet
jsp and servlet  hello friends just want to create a jsp page... login from login page and if we submit it shud be validated in a servlet using... links: http://www.roseindia.net/jsp/loginbean.shtml http://www.roseindia.net
Jsp servlet
Jsp servlet  Hai , i want add image details to database how ,please help   Here is a jsp code that allow the user to select the file and and upload it, then save it to database with some details like file path
jsp servlet hosting
jsp servlet hosting  Hi, What is jsp servlet hosting? Thanks   In case of jsp servlet hosting, hosting companies are providing hosting environment where client can host Java based web application on the server
About jsp and Servlet - JSP-Servlet
About jsp and Servlet  Servlets are directly using java technologies. It is used in HTTP,FTP..etc, But Jsp only used in HTTP. Servlets are running fastly... Then why we moved from Servlet to JSP.. Pl Tell me the reasons
code for JSP and Servlet - JSP-Servlet
code for JSP and Servlet  i have to create a jsp page that contains username and password, so how to code servlet according to it?  Hi... -------------------- loginaction javacode.LoginAction loginaction /jsp/LoginAction
connec to database - JSP-Servlet
connec to database  Need code to connect the application to database. I have developed the application JSP and Servlet
Deployment of jsp-servlet in JBoss - JSP-Servlet
Deployment of jsp-servlet in JBoss  hello, I unzipped the JBoss4.0.0. Now, I have saved the web application named "abhi" in the deployment folder . like this E:\JBOSS\jboss-4.0.0\server\default\deploy\abhi After starting
ArrayList from JSP to Servlet - JSP-Servlet
in a scriplet in a jsp page. how can i access the arraylist in a servlet which... should it be declared in jsp and in servlet. do i need to do any casting...://www.roseindia.net/jsp/servlet-jsp-data-list.shtml Hope that it will be helpful for you
java charts - JSP-Servlet
java charts  Hi,can any one tell me how to create dyanamic charts wrt database contents by using jsp-servlet
JSP - JSP-Servlet
JSP  HI! Every body............. Please send me any simple code for chatting using JSP and servlet... Advance wishes... Happy Pongal
jsp code - JSP-Servlet
jsp code  Can anyone help me in writing jsp/servlet code to retrieve files and display in the browser from a given directory.  Hi Friend, Try the following code: Thanks
ETL - JSP-Servlet
ETL  AM USING THE BACK-END AS ORACLE, MS-ACCESS. THE STRATEGY USED IS JSP/SERVLET.   Hi friend, Plz give details with full source code where you having the problem : Thanks
jsp/servlet login program - JSP-Servlet
jsp/servlet login program  hello sir, well i have a problem with some code(loginbean.jsp),which i actually got from ur site: i am trying to create a login program where a new user will be registered and his/her details stored
seeking info - JSP-Servlet
seeking info  Looking for the information on Java, JSP and Servlet... and JSP-Servlet Programs.Then check your program for all necessary files.I guess this would solve your problem.for further query read RoseIndia JSP and Servlet
java - JSP-Servlet
java  how to insert and view the image and data from database using jsp,servlet,jdbc  Hi Friend, Please visit the following links.../servlets/retreiveimage.shtml http://www.roseindia.net/jsp/retrieve-image.shtml
Add as a friend - JSP-Servlet
Add as a friend  in chat project how we send a request to add as a friend and how other peaple add me in his friend list. i want jsp-servlet and java code also.\plz.. help me on this topic
j2ee - JSP-Servlet
j2ee  please provide code for search options(example codes) or please tell me where can i get exaple codes of searh options  Hi friend, Please explain which technologies you want to use: JSP Servlet

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.