jsp-servlet

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 Tutorials/Questions & Answers:
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
Advertisements
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 - 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 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
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
J2EE - JSP-Servlet
J2EE  What is diffrent between JSP and Servlet ?   Hi friend, Difference between JSP and Servlet : Jsp have implicit object but servlet are not. Jsp is more convenient to write (and to modify!) regular HTML than
regarding web.xml - JSP-Servlet
, jsp and servlet tutorials for beginners at http://www.roseindia.net/quickguide...regarding web.xml  I am the java beginner, please send the web.xml code and how to run a servlet for apache5.0.... my problem is in tomcat manager am
small query - JSP-Servlet
small query  how to set value to textbox on browser side which is retrived from the database?  Hi friend, Plz explain problem in details which technology you have used e.g. JSP/Servlet/Java etc... For more
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
software requirements - JSP-Servlet
software requirements   In my system i have jdk1.4 and oracle8,i want work data base driven program with jsp,servlet,java,oracle,Eclipe.i want details about what's primilary s/w requirements (with version) to do
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
Project - JSP-Servlet
Project  Can you send me the whole project on jsp or servlet so that i can refer it to create my own : the topic is Advertisement Management System Atleast tell me how many modules does it include
java servlets - JSP-Servlet
java servlets  how to get the parameter value of input type file using java servlets  Hi, You can use request.getParameter(). In Jsp, --- --- IN servlet, String fileName=request.getParameter('fl'); If you
login authentication in jsp and servlet
to make login authentication in jsp and servlet? Thanks   Hi, I to make login authentication in jsp and servlet you have to write code for database... it with complete code: Login Authentication using Bean and Servlet In JSP JSP
JSP and Servlet did not run - JSP-Servlet
JSP and Servlet did not run  I tried to run this program but when I... --------- Simple Use of Servlet and JSP... the following: 1)index.jsp: Simple Use of Servlet and JSP Conference
Java - JSP-Servlet
Java  Using Servlet,JSP,JDBC and XML How to create a web application for courrier company to provide online help in tracking the delivery status... can create JSP/Servlet web application. http://www.roseindia.net/jsp
Calculator - JSP-Servlet
Calculator  Dear Deepak Sir, Calculator program is avilable in Jsp/Servlet plz send me. Thanks & Regards, VijayaBabu.M  Hi vijay calculator program in jsp function checkValue(){ var msg
servlet and jsp - JSP-Servlet
servlet and jsp  can any one give me jsp-servlet related project-its urgent- 1-chat application 2-bug tracking system 3-online shopping 4-online...://www.roseindia.net/jsp/bank.shtml Thanks
programming - JSP-Servlet
programming  hello, I am doing online exam project using jsp-servlet... to retrieve next question when click on next button in jsp page and that question will come in same jsp page. please help me how can I do
project - JSP-Servlet
can easy to generate the code in jsp and servlet, its size also medium. if you...project  plz suggest me some good projects using jsp-servlets v r doing it in group of 3 people it shouldn't be very big and also shouldn't be very
JSP Servlet Search and Edit - JSP-Servlet
JSP Servlet Search and Edit  Hi, I want to thank the people who... to the following jsp. Also, when I use it for a character column, if the backend table...){ alert(id); window.location.replace('http://localhost:8080/examples/jsp
Populating child dropdownlists in JSP/Servlet
Populating child dropdownlists in JSP/Servlet  Populating child dropdownlists in JSP/Servlet
java - JSP-Servlet
java  what is the difference between jsp and servlet?   Hi firend, Main difference between Jsp and Servlet Jsp is better for view web pages, while servlet is good for request processing. Jsp has also all
Java Mail - JSP-Servlet
Java Mail  hi, i refer ur J2EE Tutorial - Send Email From JSP & Servlet to send emails from my application.but when i run the jsp it will throw thhese exceptions. ERROR.....javax.mail.SendFailedException: Sending failed
JSP - JSP-Servlet
-- Java JSP Servlet JavaScript... on a jsp , once the user selects one of them and clicks a button (say ok) then i... new to JSP's , thank you all for ur time and support  Hi friend, I am
jsp servlet question
jsp servlet question  I have an HTML form which has a couple of radio buttons for example (gender: male/female) and some check boxes with select lists. I have created a servlet to connect to access database and process the form
jsp servlet coding issue
jsp servlet coding issue  hi, i am making a library system project in java,but i am facing problem in my code just see the code below. //thats a User class which have common variable of Library and Student.i made a register
How to Work - JSP-Servlet
about where we save the jsp and servlet file and how we link with java.send one model database program with where we save that program using jsp,servlet,java... on JSP,Servlet visit to : http://www.roseindia.net/jsp/ http
JSP Servlet update patient data - JSP-Servlet
JSP Servlet update patient data  Hi Friend, I'm attaching my inserting patient data servlet as requested. I tried your posted code, its.... Also, if you see my servlet code, you can see I am populating 2 tables based

Ads