Home Answers Viewqa JSP-Servlet How to add download option for openwith and saveAs on exporting file to excel in servlet

 
 


vikas pandey
How to add download option for openwith and saveAs on exporting file to excel in servlet
0 Answer(s)      6 months and 4 days ago
Posted in : JSP-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 Pages:
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
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
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
download
download  how to download the file in server using php code: "<form method="post" action=""> enter the folder name<input type="text" name...=readdir($dir))!=false) { ?> <option value="<?php echo $f;?>"><
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
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
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 ){ } %>
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
Download Eclipse Helios And Add The Tomcat7 For Java EE6
Download Eclipse Helios And Add The Tomcat7 For Java EE6 In this tutorial you will learn how to download the Eclipse Helios IDE and how to add the tomcat7... as : After completing the download you will get a zip file you will required
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
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
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
Excel file Handling in Java
to handle.Please explain how to read and write Excel file in Java.Is it tough... or to add data to excel file, here is a code. import java.io.*; import...Excel file Handling in Java  Hello Sir, I am new to Java, I have
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
Download Button - JSP-Servlet
. And i want the Bank customers to DOWNLOAD the mini statement. Can any one help me how to implement the download button so that on clicking that the mini...Download Button  HI friends, This is my maiden question
Excel - JSP-Servlet
Excel  How to export data from jsp to excel sheet. I am using struts1.2 in my application.  Hi friend, Code to data from Jsp to excel sheet. "abc.jsp" Enter XLS file name
how to download file
how to download file  How do I let people download a file from my page
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
download code using servlet - Servlet Interview Questions
download code using servlet  How to download a file from web to our system using Servlet
excel
excel  how to read columns values of excel file in java and store in array list in java like col1 col2 2 3 1 7 7 9 then list1 have values of col1 and list2 have values of col2...  
How to add a column in a table
How to add a column in a table   ... should know how you can modify the structure of the table. The problem is that we have to add a new column to our database by using the java program
select option with text facility - JSP-Servlet
select option with text facility  Hello. My doubt is regarding how to provide facility to add text in a drop down box ie(select tag in html )in a jsp... the select in html and if the user wants also to directly type the option instead
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
how to create text file from jsp and provide downlode option
how to create text file from jsp and provide downlode option  HI... of this page in text file and also downlode option of this text field thanks... file so that pepole can downlode that text file or may be some other file formate
Jsp to Excel
Jsp to Excel          In this section you will learn how to create an excel file and write data into it using jsp. For this, you have to import
upload and download files - JSP-Servlet
upload and download files  HI!! how can I upload (more than 1 file) and download the files using jsp. Is any lib folders to be pasted? kindly... and download files in JSP visit to : http://www.roseindia.net/jsp/file_upload
Upload and Download in JSP - JSP-Servlet
and downloading a file in JSP.. When the admin clicks upload, he must be able to upload files and similarly when the user clicks the download option, he must be able...Upload and Download in JSP  Respected Sir/Madam, I am
jsp excel code - JSP-Servlet
jsp excel code  Hi how to insert form data into excel file using jsp?  Hi Friend, Try the following code: 1)register.jsp: Registration Form First Name: Last Name: User Name: Password
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 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
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
Download a file - Java Beginners
Download a file   Hi, I need a java code to download a file from a website and before downloading it should give me an option to browse and select the location to put the file. Thanks in advance
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
PHP Open Excel File in browser - PHP
PHP Open Excel File in browser  How we can open an excel file using PHP code. I don?t want to let the user to download it rather I would like to get it open in the web browser. Any help would be great. Thank you very much
downloading excel file using Java and springs
downloading excel file using Java and springs  I need to find out how to download an excel file using the spring framework in java. Please help me out as I am new to springs and its urgent
Download PDF file
Download PDF file  How to download PDF file with JSF
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
JSP Excel report download for .xlsx format
JSP Excel report download for .xlsx format  <%@ page contentType...; The above code works fine because i am trying to save/open excel file in .xls format but my requirement is to download excel with format .xlsx (m.S 2007),so i changed
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 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
Reading And Writing Excel File
file and write it into other excel file by this way. You can add new cell... to download the excel file and code first then make folder with the name of excel...; The output of the program is given below: Download this excel file. Download
jsp - excel generating problem - JSP-Servlet
and download it.After saving the file. Then view excel file.The view image on this page is result excel file. If you have more problem then give details... (generateExcelSheet.jsp). while running the program, the excel sheet is opening in download mode
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
How to link a excel file with a application software using java swing
How to link a excel file with a application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
How to link an excel file with the application software using java swing
How to link an excel file with the application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
How to link a excel file with a application software using java swing
How to link a excel file with a application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which

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.