Exporting the datas from jsp to excel spreadsheet

Hi:
I would like to know how to publish the datas from a jsp page to an excel spreadsheet . Is there ay software I've to use or an API.
and how to use it.
Would appreciate the replies.
Thanks.

OK. Lets say you query a DB and get back a results set with 2 rows from a DB table where each row has 4 columns (all columns are string types). Here is some code that should give you the idea, note I didn't compile it so you'll have to work out the bugs.
Example data:
col1      col2       col3       col4
a1           a2          a3          a4
b1            b2          b3          b4
    public void printFile(ResultSet rs, File file) throws Exception {
        FileWriter fout = null;
        int index;
        final String DELIM = "\t";  // tab delimiter, use the character you prefer
        final String NL =  System.getProperty("line.separator", "\n")
        try {
            fout = new FileWriter(file);
            while (rs.next()) {
                  index = 1;
                  fout.write(rs.getString(index++) + DELIM + rs.getString(index++) + DELIM
                                   rs.getString(index++) + DELIM +rs.getString(index++) + NL);
        } catch(Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            try { fout.close(); } catch (Exception e) {} // do nothing

Similar Messages

  • How to export the data from table to excel sheet

    hi experts i have some problem am trying to export the data fro table to Excel sheet  in the view controller i have created one button wit public void onActionCLEAR(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionCLEAR(ServerEvent)
       //wdContext.nodeBapi_Salesorder_Getlist_Input().
       //wdContext.nodeBapi_Salesorder_Getlist_Input().invalidate();
        //@@end
      //@@begin javadoc:onActionExporToExcel(ServerEvent)
      /** Declared validating event handler. */
      //@@end
      public void onActionExporToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionExporToExcel(ServerEvent)
         try{
         FileOutputStream fos=new FileOutputStream("Test.xls");
          PrintStream ps=new PrintStream(fos);
          ps.println("<html><body><table border=1>");
          int size=wdContext.nodeBapi_Salesorder_Getlist_Input().size();
           Iterator attributes=wdContext.getNodeInfo().iterateAttributes();
           ps.println("<tr>");
           while(attributes.hasNext()){
            ps.println("<th>");
            DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
            ps.println(attrName.getName());
            ps.println("</th>");
           ps.println("</tr>");
          for(int i=0; i<wdContext.nodeBapi_Salesorder_Getlist_Input().size();i++)
            attributes=wdContext.getNodeInfo().iterateAttributes();
            ps.println("<tr>");
            IWDNodeElement ele=wdContext.getElementAt(i);
            while(attributes.hasNext()){
              ps.println("<td>");
              DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
              ps.println(""+ele.getAttributeAsText(attrName.getName()));
              ps.println("</td>");
            ps.println("</tr>");
           ps.println("</table></body></html>");
           ps.flush();
           ps.close();
           fos.close();
          catch(Exception e){
           wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);
          finally{
         //return("Test.xls")  ;
        //@@end
      }h action and i have return the code
    its running sucessfully but am not able to perform the action plz help me

    Hi,
    You shouldn't use DataAttributeInfo as it is an internal object, if I'm correct.
    Use IWDAttributeInfo instead of DataAttributeInfo and it should work
    (See also API doc of IWDNodeInfo.iterateAttributes() at http://help.sap.com/javadocs/nwce/ce711sp02/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDNodeInfo.html#iterateAttributes())
    Cheers,
    Robin

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • How can we export the data from OAF Page to Excel instead of .csv or .txt

    Hello,
    How can we export the data from OAF Page to Excel instead of .csv or .txt
    When i click on the export button it is exporting to txt file, But i need to export the data into Excel by default
    Please help me
    Thanks in advance
    Thanks,
    Raju
    We have changed the below profile option to get the data in excel by default
    Profile Name Export MIME type
    Profile Code FND_EXPORT_MIME_TYPE+
    Existing Value: text/tab-separated-values+
    Change as: Excel
    Thank you,
    Raju
    Edited by: 1006649 on May 21, 2013 10:55 AM

    We have changed the below profile option to get the data in excel by default
    Profile Name Export MIME type
    Profile Code FND_EXPORT_MIME_TYPE+
    Existing Value: text/tab-separated-values+
    Change as: Excel
    Thank you,
    Raju

  • Problem while exporting the data from a report to an excel file.

    Hi SAP guru's,
    I have a problem while exporting the data from a report to an excel file.
    The problem is that after exporting, the excel file seems to have some irrelevant characters....I am checking this using SOST transaction..
    Required text (Russian):
    Операции по счету                                    
    № документа     Тип документа     № учетной записи     Дата документа     Валюта     Сумма, вкл. НДС     Срок оплаты     Описание документа
    Current Text :
       ? 5 @ 0 F 8 8  ? >  A G 5 B C                                   
    !   4 > : C       "" 8 ?  4 > : C      !   C G 5 B = > 9  7 0 ? 8 A 8        0 B 0  4 > : C         0 ; N B 0      ! C <       ! @ > :  > ? ; 0 B K        ? 8 A 0 = 8 5  4 > : C
    Can you help me making configuration settings if any?
    Regards,
    Avinash Raju

    Hi Avinash
    To download  such characteres you need to adjust code page to be used during export. You can review SAP note 73606 to identify which code page is required for this language
    Best regards

  • Can you export the date and user to Excel that appears into a Comments field in a tracking list?

    Hi everyone,
    Can you export the date and user to Excel that appears into a Comments field in a tracking list?
    When i export a tracking list with a Comment field in the Content type, the screen where you enter the data for an item, the Comments field just export the text of the comment into the Excel file.
    In the Comments field appears also, besides the comment text,  the user and date from who and when the comment is added.
    Is there a way to export also the user and the date?
    Thanks
    Wim

    create another comment field that doesn't use 'appending', and through SP Designer change workflow keep
    updating that field with the new comments  (prepend the field with date/username/new comment). Hide the field on all forms, but put it in the view you need to export to Excel.
    Please refer few more links: Hope they will help
    http://www.nothingbutsharepoint.com/2009/04/16/versioning-append-changes-to-existing-text-view-entries-aspx/
    http://sympmarc.com/2011/02/07/showing-all-versions-of-append-changes-to-existing-text-in-a-data-view-web-part-dvwp/comment-page-3/
    https://mossipqueen.wordpress.com/2013/03/06/display-all-appending-field-entries-in-a-single-list-view/
    http://community.office365.com/en-us/f/154/t/278560.aspx
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • Is there any method to export the data from oracle 10g in any format !!!!!

    is there any methods to export the data from oracle 10g in the format of excel or csc or txt or anyother. i already downloaded the sql developer tool but it only exports the data of upto one lakh rows ,but i have two tables of more than 3 lakh and 10 lakh rows respectively.for this i used 'where' command to break the file through sql developer but that didnt work
    plz help me out if any thing possible
    i need to again import this data into microsoft sql if there is any direct method plz let me know
    its urgent
    Message was edited by:
    user628031
    Message was edited by:
    user628031

    Take a look at DUMP_CSV function by Tom Kyte.

  • HT6533 Where can I find the third party app? I'm really in trouble that I can't record and check my blood  glucose. Of cause I exported the data from app, but It's not readable for me. Please reply ASAP and give me other solution.

    Where can I find the third party app?
    I'm really in trouble that I can't record and check my blood  glucose.
    Of cause I exported the data from app, but It's not readable for me.
    Please reply ASAP and give me other solution.

    You find third-party apps in the App Store. What app are you looking for? Due to problems, Apple removed the ability to record that information in Health. You can always go back to whatever you used before three weeks Health was released. Why can you not check and record your blood glucose? I would assume you check it using blood samples and a glucose meter which has nothing to do with your phone. You should be able to record it in any number of apps, from Notes to purpose made third-party apps.

  • Reg: Exporting the data from the Physical Standby database system.

    Hello all,
    We have an oracle standard edition one 11gR1 environment, in which i need to export the data from the physical standby system.
    So can anyone suggest me, How to do it safely (mount state).
    Regards,
    Konda.

    Hi,
    You can use "exp" utility to export the database from a read only database whereas you can't export the read only database using "expdp".
    Since you are using version 11g, it is not advisable to use exp. You can convert your standby to snapshot database, open read, write and export the database using expdp and then again convert it to standby.
    This is a very easy process which we follow in our company to do testing when required.
    Follow note 11g Using Snapshot Standby Database. (Doc ID 443720.1) for converting and usage.
    Thank you!!

  • Exporting data from JSP to EXCEL

    Hi All,
    I am getting data in form of table in my jsp page. I need to know how to export the data in excel sheet with a click of button.
    Please help me.
    Thanks

    Thanks for your help
    I put the code in my jsp page. it shows a dialog box which ask the location for the excel sheet to save. However the excel it blank. It does not retrive any values from the database or jsp page
    Here is an overview of the page which i`m generating the report
    1) creating a connection object, and loading the Mysql driver
    2) getting the values from the database using select command
    3) Displaying the values in form of table
    4) in the bottom creating a button called "Export"
    5) this export will go to another page called "export.jsp"
    6) here i write the code
    <%@ page contentType="application/vnd.ms-excel" %>Plz help

  • Trying to Export the data from a webform into excel and unable do

    when i try to export the dataform from the Planning web into excel, iam unable to export it iam able to export the member name but not the data values associated to it.
    When i try to do the same by using the Mozilla, it works perfectly, iam unable to do it IE 6.
    waiting for the Valuable Suggestions on this issue.
    Regards.

    pls advise me on this issue.

  • How to send the data from jsp page to excel ???

    hi all,
    i want to send the data from my jsp form to excel sheet. any one can help me ??

    Hope this sample code might help :
    StringBuffer data = new StringBuffer();
    OutputStream ostream = response.getOutputStream();
    response.setContentType("application/vnd.ms-excel");
    response.setHeader( "Content-Disposition",
    "attachment; filename=sample.xls" );
    ostream.write(data.toString().getBytes());
    ostream.flush();
    Try it out.
    Swathi

  • I need to be able to export the data from health kit and read it in something.  Anything.

    I've tried pretty much everything from Excel to downloaded and online apps.  I'm done downloading crap to my brand new computer.  My problem is that I need to be able to export the data into a readable format so that I can give it to my dr(s).  Is there ANY WAY that this is possible?  I'm kind of at my wits end here.  All help/suggestions are appreciated.
    What I've done:
    1.  Exported data.  It creates an xml file that can be opened in excel but gives raw data that no one but egghead developers can read (and I use that term in the best possible way.)
    2. Tried to download an excel add on.  Didn't work.
    3.  Tried several online applications.  Same result as Excel.
    Somehow this data has to be able to be read by someone other than myself, on my phone.
    Thanks to one and all for the many, many suggestions that I'm about to get.

    sam.loomis1234
    The only way out of Premiere Elements 11 is via export in video format (except for jpegs or audio under Publish+Share/Computer/Image or audio).
    The video is whole, not in a project file (project.prel).
    And, the Premiere Elements 11 project.prel does not appear to be an After Effects supported project format
    http://helpx.adobe.com/after-effects/kb/supported-file-formats-effects-cs4.html#main_head1
    Have you asked this question in the Adobe After Effects Forum regarding supported formats?
    http://forums.adobe.com/community/aftereffects_general_discussion
    ATR

  • To fatch the data from sql to excel ??? any idea....

    dear all,
    my problem is - i want to retrive the data from sql server to excel sheet... can any one suggest the idea what to do ???
    thanks.

    You can open two connections. One to SQL Server (you can use a thin or JDBC-ODBC bridge), the other to your Excel spreadsheet using the JDBC-ODBC bridge. You could query the SQL Server database, massage and format your data, then write it to Excel. Excel works with a very limited set of SQL. Here is a program from a post by Tim Vickers that others sounded happy to have. I'm reposting here for your convenience. I have not personally run this program, so please use it at your own risk.
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    * Name: Excel.java
    * Purpose: To demonstrate how to use ODBC and Excel to create
    * a table,
    * insert data into it, and select it back out.
    * Version: Developed using JDK 1.3, but also works with JDK
    * 1.2.2
    * Instructions:
    * 1) Create a new Excel spreadsheet
    * 2) Create a new ODBC data source that points to this
    * spreadsheet
    * a) Go to Control Panel
    * b) Open "ODBC Data sources (32-bit) (wording may be
    * slightly
    * different for different platforms)
    * c) Under "User DSN" tab, press "Add" button
    * d) Select the "Microsoft Excel Driver (*.xls)" and
    * press
    * "Finish" button
    * e) Enter "Data Source Name" of "TestExcel"
    * f) Press "Select Workbook" button
    * g) Locate and select the spreadsheet you created in
    * Step 1
    * h) Unselect the "Read Only" checkbox
    * i) Press "Ok" button
    * 3) Compile and run Excel.java
    * 4) Open Excel spreadsheet and you will find a newly
    * created
    * sheet, GOOD_DAY, with three rows of data.
    * Notes:
    * If you want to select data from a spreadsheet that was
    * NOT
    * created via JDBC-ODBC (i.e. you entered data manually
    * into
    * a spreadsheet and want to select it out), you must
    * reference
    * the sheet name as "[sheetname$]".
    * When you create the table and insert the data using
    * Java, you
    * must reference the sheet name as "sheetname".
    * Also, do not have the spreadsheet open when you are
    * running
    * the program. You can get locking conflicts.
    public class Excel {
        public Excel() {
            setDefaults();
        private static void m(String pMessage) {
            System.out.println(pMessage);
        private void setDefaults() {
            setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
            setUrl("jdbc:odbc");
            // ODBC data source named "TestExcel" defined from
            Control Panel
            setDataSource("TestExcel");
            setTableName("GOOD_DAY");
        public void openDatabase() {
            String lConnectStr = getUrl()+":"+getDataSource();
            try {
                Class.forName(getDriver());
                gConnection = DriverManager.getConnection(lConnectStr);
            catch (Exception e) {
                m("openDatabase(): "+e.getMessage());
        private void closeDatabase() {
            try {
                getConnection().close();
            catch (Exception e) {
                m("closeDatabase(): "+e.getMessage());
        private void createTable() {
            m("createTable() begin");
            Statement lStat = null;
            try {
                lStat = getConnection().createStatement();
                lStat.execute("CREATE TABLE "+getTableName()+" ("
                +" ID INTEGER"
                +" ,NAME VARCHAR"
                +")");
            catch (Exception e) {
                m("createTable(): "+e.getMessage());
            m("createTable() end");
        private void doInsert() {
            m("doInsert() begin");
            Statement lStat = null;
            try {
                lStat = getConnection().createStatement();
                lStat.executeUpdate("INSERT INTO "
                +getTableName()+"(ID,NAME) VALUES
                (10,'KANGAROO')");
                lStat.executeUpdate("INSERT INTO "
                +getTableName()+"(ID,NAME) VALUES (20,'KOALA')");
                lStat.executeUpdate("INSERT INTO "
                +getTableName()+"(ID,NAME) VALUES (30,'PAUL
                HOGAN')");
                lStat.close();
            catch (Exception e) {
                m("doInsert(): "+e.getMessage());
            m("doInsert() end");
        private void doQuery() {
            m("doQuery() begin");
            try {
                Statement lStat = getConnection().createStatement();
                ResultSet lRes = lStat.executeQuery(
                "SELECT * FROM "+getTableName()
                ResultSetMetaData lMeta = lRes.getMetaData();
                // print out the column headers separated by commas
                for (int i = 1; i <= lMeta.getColumnCount(); ++i) {
                    if (i > 1)
                        System.out.print(", ");
                    String lValue = lMeta.getColumnName(i);
                    System.out.print(lValue);
                System.out.println("");
                // print out the data separated by commas
                while (lRes.next()) {
                    for (int i=1; i<=lMeta.getColumnCount(); ++i) {
                        if (i > 1)
                            System.out.print(", ");
                        String lValue = lRes.getString(i);
                        System.out.print(lValue);
                    System.out.println("");
                lRes.close();
                lStat.close();
            catch (Exception e) {
                m("doQuery(): "+e.getMessage());
            m("doQuery() end");
        private void run() {
            openDatabase();
            createTable();
            doInsert();
            doQuery();
            closeDatabase();
        public static void main(String args[]) {
            m("main() begin");
            Excel lExcel = new Excel();
            lExcel.run();
            m("main() end");
            System.exit(0);
        public void setTableName(String pValue) {
            gTableName = pValue;
        public String getTableName() {
            return(gTableName);
        public void setSql(String pValue) {
            gSql = pValue;
        public String getSql() {
            return(gSql);
        public Connection getConnection() {
            return(gConnection);
        public String getDataSource() {
            return(gDataSource);
        public void setDataSource(String pValue) {
            gDataSource = pValue;
        public void setDriver(String pValue) {
            gDriver = pValue;
        public void setUrl(String pValue) {
            gUrl = pValue;
        public String getDriver() {
            return (gDriver);
        public String getUrl() {
            return (gUrl);
        private Connection
        gConnection = null
        private String
        gDataSource = null
        ,gTableName = null
        ,gSql = null
        ,gDriver = null
        ,gUrl = null
    }

  • Download data from jsp to Excel

    Originally, when I was using tomcat as the web server (installed at my local machine), I wrote a jsp which allows users to download Oracle table data to a Excel file. When the user clicks "Download" data, a "File Download" dialog box pops up and asks whether the user want to "Open this file from its current location" or "Save this file to disk". That is what I want.
    Now, I migrate the application to OC4J (installed at Sun Solaris Server), the same program is not working as the same way as above. If the user clicks the link, then the program simply display the jsp page. In order to download data, the user needs to right click the link and selects "Save Target as".
    How to make the application work just like it works on tomcat? Is this a programming issue or a server configuration issue?
    Thanks.
    Jingzhi

    Hi,
    I am having the same exact problem that you had months ago. Would love to hear if you came up with a solution? Original post included below...
    Thanks,
    Andres
    ORIGINAL POST:
    Hi
    I could successfully send the data from a jsp file to a excel file. But, I have a problem with the data. The data i pass is normally alpha numeric, but some times the data is something like '00123456'. In such cases, i am loosing the leading zeros and get '123456'. Is there any way i can get around with this problem?
    Help is greatly appreciated.
    Bharat

Maybe you are looking for

  • Need your help !!! -- Authorization error for Real-Time Bex query

    Dear experts: I have a Bex query built on a multiprovider, this multiprovider is consist of one standard cube and one real-time cube(virtual provider). When I run this query, I can retrive the data and no error occured, but when others execute this q

  • Months later and I still cannot update to IOS 5.1!!!

    You name it, Ive tried it.  Done all the different trouble shooting bits and bobs, ie uninstalled security, itunes reinstalled ,disabled apple mobile, used a different pc, etc yet still i cannot update my ipad? I even ventured to my local Apple store

  • Pass variable to subreport

    I'm using SQL Server 2014 and Reporting Services and I've got a report containing a number of linked subreports. The main report I have will be different for each customer I produce the report for and will contain different text, but I need to pass a

  • KP06 Planning Excel Problem

    Hi All, I have issue withn KP06 Planner Profile with Excel Uploading,when I do Excel Uploading it is working well but once I verify the results I came to know only few months got uploaded eventhough I have numbers for all 12 months in my uploaded exc

  • How to work with text objects in b2b frontend

    Hi, My functional team has assigned new text ids "0012","Z005" and "Z025" in text object "CRM_ORDERH" and text procedure "ZORDER02". Now they want me to add five new text input fields to b2b order creation page and they want the data entered by custo