Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet SaveAs Dialogue box is not working on button click in servlet
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vikas pandey
SaveAs Dialogue box is not working on button click in servlet
0 Answer(s)      a year and 11 months ago
Posted in : JSP-Servlet


Hii Sir, i added response.setHeader into my servlet code to export the data into excel file but this is not working on button click ...plz give me the write code. Thank you Sir.

response.setHeader("Content-Type", "application/vnd.ms-excel"); response.setHeader("Content-Disposition","attachment; filename=excel.xls");

String datum1 = request.getParameter("fromdate");
String datum2 = request.getParameter("todate");
SimpleDateFormat sdfSource = new SimpleDateFormat("dd-MM-yyyy");
Date date = sdfSource.parse(datum1);
Date date2 = sdfSource.parse(datum2);
SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd");
datum1 = sdfDestination.format(date);
System.out.println(datum1);
datum2 = sdfDestination.format(date2);
System.out.println(datum2);


HSSFWorkbook hwb = new HSSFWorkbook();
HSSFSheet sheet = hwb.createSheet("CallBillingSystem");

HSSFRow rowhead = sheet.createRow((short) 0);
rowhead.createCell((short) 0).setCellValue("calldate");
rowhead.createCell((short) 1).setCellValue("src");
rowhead.createCell((short) 2).setCellValue("dst");
rowhead.createCell((short) 3).setCellValue("dstchannel");
rowhead.createCell((short) 4).setCellValue("lastapp");
rowhead.createCell((short) 5).setCellValue("duration");
rowhead.createCell((short) 6).setCellValue("disposition");
rowhead.createCell((short) 7).setCellValue("amaflags");
rowhead.createCell((short) 8).setCellValue("cdrcost");


String strQuery = "";
ResultSet rs = null;

conexion conexiondb = new conexion();
conexiondb.Conectar();

strQuery = "SELECT * FROM cdrcost where date(calldate) between '" + datum1 + "' and '" + datum2 + "'";

 //strQuery = "SELECT * FROM cdrcost where date(calldate) between '2011-09-01' and '2012-01-01'";

rs = conexiondb.Consulta(strQuery);
int i = 1;
while (rs.next()) {
    HSSFRow row = sheet.createRow((short) i);
    row.createCell((short) 0).setCellValue(rs.getString("calldate"));
    row.createCell((short) 1).setCellValue(rs.getString("src"));
    row.createCell((short) 2).setCellValue(rs.getString("dst"));
    row.createCell((short) 3).setCellValue(rs.getString("dstchannel"));
    row.createCell((short) 4).setCellValue(rs.getString("lastapp"));
    row.createCell((short) 5).setCellValue(rs.getString("duration"));
    row.createCell((short) 6).setCellValue(rs.getString("disposition"));
    row.createCell((short) 7).setCellValue(rs.getString("amaflags"));
    row.createCell((short) 8).setCellValue(rs.getString("cdrcost"));
    i++;
}
FileOutputStream fileOut = new FileOutputStream(filename);
hwb.write(fileOut);     
hwb.write(response.getOutputStream());
System.out.println("Your excel file has been generated!");
FileOut.close();

} catch (Exception ex) { System.out.println(ex);

}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
SaveAs Dialogue box is not working on button click in servlet
SaveAs Dialogue box is not working on button click in servlet  Hii Sir, i added response.setHeader into my servlet code to export the data into excel file but this is not working on button click ...plz give me
get a radio button click value - JSP-Servlet
get a radio button click value  thanks sir for sending code ,but i...") in servlet that is used in another jsp so can i call getParameter("radio") i.e... servlet from another jsp i.e 'main.jsp', then you have to store the value of id
Advertisements
on click button php
on click button php  Function in PHP for on click button
click on check box
click on check box  I create a check box in HTML and when i click on my check box relative information in page store in database
css click box
css click box  I wanted to create a click box in CSS with a hyperlink that should appears flat.   Find the below given code.. In your HTML file .. click box Text CSS a { display:inline-block; width:30px
passing values on button click
passing values on button click  Please help me to solve this issue.I want to pass a value assigned to button to another view upon button click in xcode
iphone button click event
iphone button click event  Hi, How to write iphone button click event? Thanks   Hi, Here the method declaration: -(IBAction) myMetod...{ NSLog(@"Button clicked"); } Thanks
jquery button click
jquery button click  jquery button click - I have created a button in JQuery but the problem is that it's not detecting click. What could... to create a button event in JQuery. You can edit it as per your requirement. In Header
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
java swing button click event
java swing button click event  java swing button click event   public void doClick()   Java Swing Tutorials
How to add download option for openwith and saveAs on exporting file to excel in servlet
How to add download option for openwith and saveAs on exporting file to excel in servlet  Hii Sir, I made an application in which i need to export... my requirement I need to give download option for openwith and saveAs from
How to add download option for openwith and saveAs on exporting file to excel in servlet
How to add download option for openwith and saveAs on exporting file to excel in servlet  Hii Sir, I made an application in which i need to export... my requirement I need to give download option for openwith and saveAs from
adding a dialogue
adding a dialogue  Blockquote Hi can you help with the program below,the program is a loop that prints out a code and a quantity when prompt for the user input.what I need is to modify the code to incorporate a dialogue asking
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
Browser Back Button click event javascript
Browser Back Button click event javascript  I am using the below code but window.onBeforeUnload is not working with back button.. how can i apply the below code for the click event of back button? window.onBeforeUnload
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in Java  Draw a line in a JPanel with button click in Java
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
Call a servlet on click of hyperlink
Call a servlet on click of hyperlink  Call a servlet on click... the servlet url of desired servlet as href="<%=request.getContextPath()%>/CallServlet? . CallServlet is the url of the Servlet. <html>
SubCombo box not working - Development process
SubCombo box not working  Hi, in the following code subcombo box is not working and while storing combo box numbers(1,2,3) are stored instead of values. Search Page var arr = new Array(); arr[0] = new
On Click on Submit Button Display Data on Orderlist
On Click on Submit Button Display Data on Orderlist  How can retreive data from database on orderlist on Click on submit Button of same page
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
click on back button go to the login page
click on back button go to the login page  now when i click on back button the page show that page on where i came from and it shows the session expired but i want when i click a back buttob then it should show a login page
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
Click On Images of Submit Button Perform Action
Click On Images of Submit Button Perform Action  I have login page in which insert of submit button i used image. Therefor on Click of image i have to validate form , link with database and goto the next page
print form information when click on print button
print form information when click on print button   Sir,I desingn institute webside using jsp and strut by using platform netbean 7.2.So request you please help for printing form information by clickin print button after submit
Open website on Button Click - Java Beginners
Open website on Button Click  Hello sir I want to open website on button click using java swing plz help me sir. in my swing application one "VISIT US BUTTON" i want to open my website on Button CLick  Hi Friend
iPhone Button Click Sound
iPhone Button Click Sound In this series of iPhone button tutorial, we... the application to listen the sound on button click. The sound file that i have used... on clicking the button in iPhone SDK. For the audio we are going to use
Click on Page Refresh - JSP-Servlet
Click on Page Refresh  hi ,i am working on jsp with mysql. i m facing a problem whenever i click on page refresh or f5 button, the value on form... the condition in which record insert in the database only when the "submit button
Expand / Collapse form div when click on button
Expand / Collapse form div when click on button  Hi, I have a form integrated from Wufoo with iFrame code. If the user misses a field an error message appears but it takes more space than the DIV Formbox. How can I make the DIV
 

 

 

DMCA.com