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 data from database into .excel formate in which i have given hard coded path for generated .excel file to save at particular position on the system.Now as per my requirement I need to give download option for openwith and saveAs from the browser. Below I am postion my code .Plz guys help me ...will be gratefull.Thanx in advance...

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);

        String filename = "d:/".concat(datum1).concat(" ").concat("To").concat(" ").concat(datum2).concat(".xls");
        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");

        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"));

            i++;
        }
        FileOutputStream fileOut = new FileOutputStream(filename);
        hwb.write(fileOut);
        fileOut.close();
        System.out.println("Your excel file has been generated!");

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

    }


}
View Answers









Related Tutorials/Questions & Answers:
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... for generated .excel file to save at particular position on the system.Now as per 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... for generated .excel file to save at particular position on the system.Now as per my requirement I need to give download option for openwith and saveAs from
Advertisements
how to create xls file and give download option using jsp/servlet?
how to create xls file and give download option using jsp/servlet?  Hi, how to create file and give download option to user,so that the user can save the file on defined path
how to insert excel file into mysql datbase in servlet
how to insert excel file into mysql datbase in servlet  emphashow to insert excel file into mysql datbase inservletized text
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
How to upload a large excel file - JSP-Servlet
How to upload a large excel file   Dear sir , How to upload a large excel file and how to read a that large excel file or how to get a each column values from that large excel file.For small file i am getting values
Download file - JSP-Servlet
Servlet download file from server  I am looking for a Servlet download file example
How to download web page table data, export the table records in an excel file and save
How to download web page table data, export the table records in an excel file... be exported in to the excel file. any views??? Thanks in advance... the download link. when i click on the link download pop up box should
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 on it ,it is displaying a alert box stating "the file you are trying to open
download excel
download excel  hi i create an excel file but i don't i know how to give download link to that excel file please give me any code or steps to give download link
JSP file download - JSP-Servlet
JSP file download  Hi! I am saving (webapp/docs/sample.docx) path of the word file in database. when i want to download that file i am eliminating... to download word file: <% ServletOutputStream output
Upload and download file - JSP-Servlet
......... Now to download the word document file, try the following code...(); response.getOutputStream().flush(); %> Thanks   I want to download a file... the destination location where to download the file
how to download file
how to download file  How do I let people download a file from my page
exporting data to excel sheet - JDBC
exporting data to excel sheet  Sir i have already send request about... query in java swing program,i want to print the result about the query in excel... = wb.createSheet("Excel Sheet"); try{ Connection con = null
retrieving of value from excel file - JSP-Servlet
file so please help me how to take a parameter after uploading a file... Thanks...retrieving of value from excel file  Dear sir, Thanks for sending... this message to all the employees when i upload a file then it fetch a data from
retrieving of value from excel file - JSP-Servlet
file so please help me how to take a parameter after uploading a file...retrieving of value from excel file  Dear sir, Thanks for sending... this message to all the employees when i upload a file then it fetch a data from
SaveAs Dialogue box is not working on button click in servlet
the data into excel file but this is not working on button click ...plz give me...); hwb.write(response.getOutputStream()); System.out.println("Your excel file has...SaveAs Dialogue box is not working on button click in servlet  Hii
How to read a rows which have a values in a excel file using apache poi - JSP-Servlet
How to read a rows which have a values in a excel file using apache poi  Dear sir, How to read excel file in that only a rows which are having some values using apache poi...please help me sir. Thanks and Regards
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
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 sending a email,while sending a email if i attached a file that should be read
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks... to all the employees that are in the excel sheet.So in the previous code i have got... mailids,so how to get a different column values please help me sir,giveme some
Capture browser file download event - JSP-Servlet
Capture browser file download event  Hi, I appreciate your help and thaanks for that.But my question was when filedownload dialog box comes in browser,how we can come to know that user has clicked on Open,save or cancel button
File Upload And download JSP Urgent - JSP-Servlet
File Upload And download JSP Urgent  Respected Sir/Madam, I... Ragavendran, i am sending code of file download in jsp. Plz implement this code. file download in jsp
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
how to download a file from a folder??
how to download a file from a folder??  i can upload any kind of files to a folder, and only the path of the file is saved into the database, now how a client can download the file from my folder. pls provide me the jsp code
How to upload and download file in hadoop?
How to upload and download file in hadoop?  Hi, I am trying to learn to upload the file on the Hadoop HDFS and then download the same file for learning the process. How to upload and download file in hadoop? What
How to insert rows from Excel spreadsheet into database by browsing the excel file?
the excel file using file browsing dialogue through form in JSP. How can i select...How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code
sir, how to read empty cell in excel file using poi and how to add this empty... nameis sample.xls and this file contain some blanks cells how to read and how...) cellIter.next(); //if it is empty cell in my excel file
how to display the excel file content in the jsp
how to display the excel file content in the jsp  How to present the content of the newly created excel file in the following jsp to the web browser...="application/vnd.ms-excel" %> <%@ page import="java.io.*" %> <
how to display the output of the newly created excel file
how to display the output of the newly created excel file  the following program will create the test.xlsx file, how can i display the content of the test.xlsx file in the web browser? thanks, %@ page import
how to display the excel file in the web browser.
how to display the excel file in the web browser.  > %@ page.../vnd.ms-excel" > %> <%@ page import="java.io.*" %> <% >... FileOutputStream > ("c:\\excel\\aqtemplate.xlsx"); > wb.write
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
how to add a file in GZIP
how to add a file in GZIP  Hi, how to add a file in GZIP using Java.   Hi, I have found a good referral site for How to Add a file in GZIP file format using Java. http://www.roseindia.net/java/examples/io
How to download a file from URL in Java?
How to download a file from URL? If you are looking for example code in Java... is for you. You will learn how to write code in Java for downloading a file from URL and then saving the file on your computer. In this tutorial you will learn how
How to add another option to the select tag using struts2 tag - Struts
How to add another option to the select tag using struts2 tag  Hi, How to add another option to select tag using tag. My scenario is : If the logged in user is admin then drop down should contain the normal list
How to delete excel file records using Store Procedure?
How to delete excel file records using Store Procedure?  Hi.. I have created one Excel file through stored procedure.Now I want to delete records or delete excel file. Thanks
File download from server to client machine - JSP-Servlet
File download from server to client machine  hi, I want to save a pdf file to my client machine from a button provoded in a jsp page.The file that was generated by jasper libraries.In my code i can give path for save
How to add save as dialoguebox to export into excel instead of directly saving..
How to add save as dialoguebox to export into excel instead of directly saving..  Hello Sir, i followed ur tutorial to export into excel from database and generated excel file at particular directory of my system
how to create a php script to download file
how to create a php script to download file  php script to download file
how to create text file from jsp and provide downlode option
how to create text file from jsp and provide downlode option  HI... file so that pepole can downlode that text file or may be some other file...; </table> <a href="/documents/large_document.pdf">Download
file download
file download  I uploaded a file and saved the path in database. Now i want to download it can u plz provide code
how to add the scrollbar to the pdf page when generating the pdf file from jsp - JSP-Servlet
how to add the scrollbar to the pdf page when generating the pdf file from jsp  I am not able to see all the columns when i generated the pdf file from jsp.i have 12 colums so how to add the scrollbar
how to add the two tables in same row when generating pdf file from jsp - JSP-Servlet
how to add the two tables in same row when generating pdf file from jsp  How to add the two tables in same row one is left side and other is right side please help me.   Hi Friend, Try the following code
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java    How to export data from html file to excel sheet by using java
How to import data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase??
How to import data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase??  How to import data from sql server table into an excel file by creating the rows dynamically
How to open excel sheet when excel file is placed in some folder in desktop
How to open excel sheet when excel file is placed in some folder in desktop  How to open an excel sheet using windows.open in IE... I am getting an error msg that the path is not correct.. But i have specified the correct path
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...(); out.println("Data is saved in excel file."); }catch ( Exception ex ){ } %>
How to Read Excel file Using Java
How to Read Excel file In this section,you will learn how to read excel file... and every cell and stored the excel file values into the vector.This Vector data is then used to display file values on the console. Here is the code
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- text1,text2,text3,....,upto text30... i want to export this data in csv file

Ads