Read/Write MS Excel file in Java

Hi,
I want to read Excel file & displau excel sheet data on HTML format.
I was tried with POI.
But i m now aware with POI.
thanks in advance.

Greetings.
As I know, POI is one of the best solutions in this direction. You may try some other packages listed on http://schmidt.devlib.org/java/libraries-excel.html.
Sincerely,
wanderlust

Similar Messages

  • Pls How do I read/write a xml file using java

    I want to read/write trough a server/client a file.xml from evt. the same computer, this is the code for the client
    import java.io.*;
    import java.net.*;
    class client
    public static void main (String args[]) throws Exception
    final String msg = "<beg>note</beg>";
    // BufferedReader in = new BufferedReader(new FileReader("note.xml"));
    final Socket clientSocket = new Socket ("localhost", 8000);
    final OutputStream clientStream = clientSocket.getOutputStream ();
    clientStream.write (msg.getBytes ());
    // clientStream.write (in.getBytes ());
    clientSocket.close ();
    // BufferedReader in = new BufferedReader(new FileReader("note.xml"));
    // System.out.println(in.readLine());
    I want to read it and put it in a buffer...
    please somebody help me!!!
    regards
    Harry

    Pls read this:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=271751
    And don't post the same message twice. It's annoying.

  • Read, Write and create files from java applet.

    Dear All,
    I have created a two files. One is applet and one application file. I am creating a instance of application file in applet. Application file is used for reading, writing and creating files. When I invoke applet from broser it dipslays error wrt file access permission. From the forum search I know that we need to sign the applet / edit the java policy to run the code locally. Final delivery of my code should execute on different system. Its not web. I have created a html page on submitting the form it invokes applet to read the form values from param and needs to update the values in xml file located locally. Please help me on how I can proceed with this fix.
    Thanks in advance.

    Sorry if I have not stated the problem clearly. I need to update content to files hosted in local system using java applets.
    I belive there are two ways to achive that.One with jar signer and one with modifying the java policy file. But this application needs to be installed in different system locally as I have created a application with webpage as useinterface and need to update the content in local files on submission. Not sure on how to modify the java.policy files in each end user system and whats the value we need to update in java policy file. Please help me on the steps to be followed

  • Read & write from external files in java

    Hello everybody,
    I need your help in two problems. I have to write a method that read specific numbers from a file, save them in an array, do some calculation on that array and write it again in a new file.
    For example, I have a file that contains the following:
    #VRML V1.0 ascii
    Material {
    diffuseColor [ 1 1 1 ]
    ShapeHints {
    vertexOrdering COUNTERCLOCKWISE
    shapeType UNKNOWN_SHAPE_TYPE
    Coordinate3 {
    point [
              1 0 0 ,
              1 1 0 ,
              1 1 1 ,
              1 0 1 ,
              0 1 0 ,
              0 1 1 ,
              0 0 1 ,
              0 0 0 ,
    IndexedFaceSet {
    coordIndex [
    0,1,2,-1,
    0,2,3,-1,
    1,4,5,-1,
    1,5,2,-1,
    3,2,5,-1,
    3,5,6,-1,
    0,3,6,-1,
    0,6,7,-1,
    6,5,7,-1,
    7,5,4,-1,
    0,7,4,-1,
    0,4,1,-1,
    I need to read the point coordinates only and save them in a two dimension array, then I'll do some transformation on that array and write it in a new file that contains the previous data but the point coordinates are the transformed coordinates. I tried the following:
    FileReader in = new FileReader("C:\\hexahedron.txt");
              BufferedReader br = new BufferedReader(in);
              String line;
              StringTokenizer s;
              int [][] point = new int [8][3];
              int row = 0;
              int column;
              while ( (line = br.readLine()) != null) {
                   s = new StringTokenizer(line);
                   column = 0;
                   while (s.hasMoreTokens()) {
                        if ( s.nextToken() == "[" ){
                             point [row][column++] = Integer.parseInt(s.nextToken());
                   row++;
              br.close();
              in.close();
    But when I tried it, I found out that it saves 0s in the array!
    As I mentioned before, my problem is that I don't know how to read specific information from a file. I know how to write new information a file, but how to write a file that I already have with changed specific information.
    I'll be grateful if you show me how to solve those problems.
    And I hope that I explained my problems in an understandable and clear way.
    Regards,

    if ( s.nextToken() == "[" ){should beif (s.nextToken().equals("["){Also, you have two nextToken for each has hasMoreTokens, which is going to cause an exception.
    You are never hitting the parseInt code because of your equals/== error. Therefore, everything is zeros.
    The order of reading lines and checking for "[" isn't right. You should find the [ (maybe including the "point" word), then get numbers from the following lines (read line, tokenize, read line, tokenize, ...) until you hit the end of the points.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Read&write Excel file using java

    Hi everybody,
    I have an assignment about methods that read and write an excel file using java (Eclipse SDK), so if anyone know about that please post the solution as soon as possible.
    Thanks
    Sendbad

    http://onesearch.sun.com/search/onesearch/index.jsp?qt=read+write+excel&subCat=siteforumid%3Ajava31&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&col=developer-forums

  • How to format a excel file use java.

    hi,
    everyone, i meet a problem.i want to write a excel file use java.i can use .csv input the date to excel.but i want to know how to format it.
    thanks
    Jove

    hi,
    everyone, i meet a problem.i want to write a excel
    el file use java.i can use .csv input the date to
    excel.but i want to know how to format it.
    thanks
    JoveIf I understand your question correctly you need to know the format of a .csv file for use in an Excel spreadsheet. A .csv file is a comma-delimited file so all that you need to do is write your data elements to the file with commas in between them. Having done something similar in the past, let me warn you that when Excel is reading your file, it uses some characters other than commas as field delimiters. for example, / : and ; are treated as commas. To defeat this, you will need to surround fields containing those characters in double quotes.
    Hope that helps
    Mark

  • How to read Excel file in java

    Respected sir/madam
    I want to read the values from Excel file in Java program. How can I do that. When I searched over the net I came to know that you can treat Excel file as a Database and write the code as u write for making DB connections .
    I did that but i am getting the following error ..can anybody please help..
    This is the code what i have written
    import java.io.*;
    import java.sql.*;
    public class ReadExcelFile {
    Connection c;
    Statement stmnt;
    public void checkABA_Number()
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c = DriverManager.getConnection("jdbc:odbc:ExcelTest","",""); // ExcelTest is the DSN name
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from abadata"); // abadata is my Excel file name
    while(rs.next())
    System.out.println(rs.getString(1)+" "+rs.getString(2));
    }catch(Exception e)
    System.out.println(""+e.toString());
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    public static void main(String[] args)
    new ReadExcelFile().checkABA_Number();
    My Excel file starts from the first row and first column and also the first row contains the names of the column.
    It give me the following error..
    java.sql.SQLException: [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'abadata'. Make sure the object exists and that you spell its name and the path name correctly.
    How can I deal with this.?I have properly selected the worksheet while giving the DSN . Is there any versionig problem with Excel or some drivers are in appropriate..and yes i chose Microsoft Excel Driver (.xsl) from ODBC .
    I created System DSN.
    Can anybody please help me with this ? I will be very gratefull for replies
    Thanks in advance

    here is the code to read excel file
    public void readexel(String filename)
    Connection c = null;
    Statement stmnt = null;
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + filename);
    stmnt = c.createStatement();
    String query = "Select * from [Sheet1$]" ;
    ResultSet rs = stmnt.executeQuery( query );
    while( rs.next() )
    System.out.println( rs.getString(1) );
    catch( Exception e )
    System.err.println( e );
    }

  • How to Write data in Excel File using java

    Hi
    can anybody help me to write data in excel file
    using java code
    Thankx In Advance

    How much are you willing to pay for that?
    If you want it for free, http://jexcelapi.sourceforge.net/

  • How to read a Excel file through java coding

    Hi,
    *I need to have a code with reads data from excel file. Could u forward the jar files needed for that also.
    *presently we are using client systems so we are not able to get the following jar files. Please sent these jar files inorder to proceed me to write module processor or for writing java proxies.
    • aii_af_cci.jar
    • aii_af_mp.jar
    • aii_af_ms_api.jar
    • aii_af_ms_spi.jar
    • aii_af_trace.jar
    • aii_af_svc.jar
    • aii_af_cpa.jar
    Thank u

    Hi Shaker thank u ,
    but plz forward the jar file needed to read that is "jxl.jar" and the other jar files defined in earlier  message, to my mail id .
    just for confiramtion i defined again here:
    • aii_af_cci.jar
    • aii_af_mp.jar
    • aii_af_ms_api.jar
    • aii_af_ms_spi.jar
    • aii_af_trace.jar
    • aii_af_svc.jar
    • aii_af_cpa.jar
    jxl.jar
    Thank u

  • Reading Excel files in Java --

    Hi,
    I am trying to read an excel file from Java. It only reads the column, but I want to print the rows, which intersect with the SQL query. The following source displays only values of a column. No problem, but I would like to see the corresponding row numbers or simply number of rows. Can anyone suggest me what to do ASAP?
    Thanks,
    Gunter
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class ExcelReadTest1{
    public static void main(String[] args){
    Connection connection = null;
    try{
    //Vector vector = new Vector();
    String myString="";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection( "jdbc dbc ata-list" );
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery( "Select caseid from [sa3$] where iSchool=2" );
    //ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    int row_num=1;
    while ((rs !=null) && rs.next()) {
    myString += "\n Row " + row_num++ + " ";
    for (int i = 1; i <= numberOfColumns; i++)
    //myString += "\n " + rsmd.getColumnName(i);
    myString += " : " + rs.getString(i);
    System.out.println(myString);
    if (i >1)
    System.out.print(", ");
    String columnValue = rs.getString(i);
    System.out.print(" " + columnValue);
    System.out.println("");
    st.close();
    con.close();
    } catch(Exception ex) {
    System.err.print("Exception: ");
    System.err.println(ex.getMessage());

    I took your code and reworked it to access a little database I keep of students at a small private school where my wife works. The Student table has columns "studentID", "firstname", "lastname", and "gradyear".
    Running your code for the output got the following. I cut and pasted the output after it had run through the first 4 students, so you can see what it's doing.
    Row 1 : 1
    1
    Row 1 : 1 : Audrey
    , Audrey
    Row 1 : 1 : Audrey : Budington
    , Budington
    Row 1 : 1 : Audrey : Budington : 2015
    , 2015
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2
    2
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia
    , Cecilia
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo
    , DeRigo
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    , 2015
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3
    3
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena
    , Serena
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes
    , Downes
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    , 2015
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4
    4
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan
    , Dylan
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan : Gellert
    , Gellert
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan : Gellert : 2015
    , 2015
    You need to figure out the flow of the thing and your println() calls and your looping. Eventually if you straighten it out you will get something like
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan : Gellert : 2015
    Row 5 : 5 : Benjamin : Miller : 2015
    Row 6 : 6 : Timothy : Bolan : 2014
    Row 7 : 7 : Javin : deMello-Folsom : 2014
    Row 8 : 8 : Elizabeth : Eppolito : 2014
    Row 9 : 9 : Harrison : Evans : 2014
    Row 10 : 10 : Emily : Fay : 2014
    *** etc***
    which is what you want, isn't it?

  • Read data from Excel file and diaplay in Webdynpro

    Hi all,
    I need some help. I have a Excel file with set of  name, phonenumbers . I want to know how to display the data using Webdynpro. Could some one help me. help is appreciated and I promise to award points for right answer.
    Thank you
    Maruti

    <b>Hi
    i can explain you to read data from Excel file
    First You have to download the jxl.jar file. You can get this file from the Below site
    </b><a href="http://www.andykhan.com/jexcelapi/download.html">jexcelapi jar</a>
    It will be in Compressed Fromat So Unzip it to get the Contents
    After Unzipping The File You will get a Folder (jexcelapi/jxl.jar)
    Now in NWDS open web dynpro explorer, Right Click Your Project, a popup menu will appear and in that click Properties
    You will get window displaying your Project Properties
    On Left Side of the window You Will Find "Java Build Path"
    Click That "Java Build Path" and you will get 4 Tabs Showing ( Source,Projects,Libraries,Order and Export)
    Click Libraries Tab
    You will find options many options buttons
    In that click the Button "Add External Jars"
    You will get Window in order to fecth the jxl.jar file from the location you had stored
    After selecting the jxl.jar i will get displayed and click ok
    Now Open Navigator
    Open Your Project
    You will find Lib folder
    Copy the jxl.jar to that lib folder
    Note : You cannot Read the Content from the excel file directly
    First You Have to copy that file to the Server,
    And from the Server you can get the file absolute path
    With the absolute path you can read the contents of the Excel file
    You have to save the Excel file as .xls Format and Not as xlsx format i will not accept that...
    You have Upload the Excel file from the Server Using the File Upload UI Element
    This Coding will extract 3 columns from the Xls File
    Coding
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import com.sap.fileupload.wdp.IPrivateFileUpload_View;
    import com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource;
    public void onActionUpload_File(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUpload_File(ServerEvent)
        IPrivateFileUpload_View.IContextElement element1 = wdContext.currentContextElement();
        IWDResource resource = element1.getFileResource();
        element1.setFileName(resource.getResourceName());
        element1.setFileExtension(resource.getResourceType().getFileExtension());
        //@@end
    public void onActionUpload_File_in_Server(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUpload_File_in_Server(ServerEvent)
        InputStream text=null;
        int temp=0;
        try
             File file = new File(wdContext.currentContextElement().getFileResource().getResourceName().toString());
             FileOutputStream op = new FileOutputStream(file);
             if(wdContext.currentContextElement().getFileResource()!=null)
                  text=wdContext.currentContextElement().getFileResource().read(false);
                  while((temp=text.read())!=-1)
                       op.write(temp);                                      
             op.flush();
             op.close();
             path = file.getAbsolutePath();
             wdComponentAPI.getMessageManager().reportSuccess(path);
        catch(Exception e)
             e.printStackTrace();
        //@@end
    public void onActionUpload_Data_into_Table(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUpload_Data_into_Table(ServerEvent)
        try
              Workbook wb =Workbook.getWorkbook(new File(path));
              Sheet sh = wb.getSheet(0);
              //wdComponentAPI.getMessageManager().reportSuccess("Columns = "+sh.getColumns());
              //wdComponentAPI.getMessageManager().reportSuccess("Rows = "+sh.getRows());
              int columns = sh.getColumns();
              int rows = sh.getRows();
              int i=0;
             for(int j=1;j<=rows;j++)
                       ele=wdContext.nodeTable_Data().createTable_DataElement();
                       Cell c1 = sh.getCell(i,j);
                      ele.setTab_Name(c1.getContents());
                       Cell c2 = sh.getCell(i+1,j);
                       ele.setTab_Degree(c2.getContents());
                          Cell c3 = sh.getCell(i+2,j);
                       ele.setTab_Percentage(c3.getContents());
                       wdContext.nodeTable_Data().addElement(ele);
        catch(Exception ex)
             wdComponentAPI.getMessageManager().reportSuccess(ex.toString());
        //@@end
       * The following code section can be used for any Java code that is
       * not to be visible to other controllers/views or that contains constructs
       * currently not supported directly by Web Dynpro (such as inner classes or
       * member variables etc.). </p>
       * Note: The content of this section is in no way managed/controlled
       * by the Web Dynpro Designtime or the Web Dynpro Runtime.
      //@@begin others
      String path;
      IPrivateFileUpload_View.ITable_DataElement ele;
    //@@end
    Regards
    Chandran S

  • Formatting an Excel File in Java

    Hi,
    I have created a Excel file in Java, But i want to put each column with a specific width. How can i do this?
    Help anyone?

    I have this piece of code.
    outputFile=new java.io.File(vVirtualDir+nomeFicheiro.toString());
    java.io.FileWriter out1 = new java.io.FileWriter(outputFile);
    String dados="\15\12";
    out1.write("\15\12");
    dados+="Column Name 1";
    dados+="Column Name 2";
    dados+="Column Name 3";
    dados+="\15\12";
    dados+="Regsiter1";
    dados+="1";
    dados+="1";
    dados+="\15\12";
    dados+="Regsiter2";
    dados+="2";
    dados+="2";
    dados+="\15\12";
    String res =new String(dados.getBytes("ISO-8859-1"));
    out1.write(res);
    out1.close();
    This creates me the content of a Excel File. But i want to define the width of each column. How can i do that?

  • Generate Excel File using Java

    Hi,
    could any one tell me how can I create an Excel file using java. I can create the file using PrintWriter and other IO classes. But how do I insert the data in to different cells and rows.
    Any help would be greatly appreciated. Thanks in advance for your help,
    -MS

    Dear All,
    There are three ways for achiving excel operations using java including excel to xml etc.
    1. There is a very effective tool available for this operation is "jexcel". You can find it at http://www.andykhan.com/jexcelapi/index.html
    2. Jakarta site has provided a very good tool by name jakarta poifs. one can find at jakarta site.
    3. One can develop a very effective tool by combining these above tools togather.
    The operations that can be performed are read, write, convert etc for excel. The major attraction of Jexcel is excel to xml conversion.
    Regards,
    Nishant Kulkarni
    Software Engineer
    [email protected]

  • How to read/write a binary file from/to a table with BLOB column

    I have create a table with a column of data type BLOB.
    I can read/write an IMAGE file from/to the column of the table using:
    READ_IMAGE_FILE
    WRITE_IMAGE_FILE
    How can I do the same for other binary files, e.g. aaaa.zip?

    There is a package procedure dbms_lob.readblobfromfile to read BLOB's from file.
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#sthref3583
    To write a BLOB to file you can use a Java procedure (pre Oracle 9i R2) or utl_file.put_raw (there is no dbms_lob.writelobtofile).
    http://asktom.oracle.com/pls/ask/f?p=4950:8:1559124855641433424::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6379798216275

  • How to save html as Excel file im java

    Hi to all
    How can i save html file as Excel file in Java
    If any solutions plz help Me

    Thanks for ur reply
    Source URL is::http://www.sttpc.com/reseller/price.htm
    Target is to save table data into Excel Sheet.
    Upto saving that file as Excel file its working (using I/O).
    When iam trying to read excel sheet data then iam getting OLE Exception.
    plz suggest me other Alternate solutions to overcome this problem.
    I tried htmlparser from sourceforge.net i got partial ouput.But i want dynamic solution.
    Thanks.

Maybe you are looking for

  • HT201303 how can I remove a payment method such as a credit card off of my account?

    I can't figure out how to remove it.

  • Cannot change the nickname/label in my .mac profile

    Mountain Lion completely hosed my 2 year old MacBook Pro. Slow -- beachballs all the time. SNL was great, oh why did I have to be an idiot and upgrade to the Vista of Apple. I have a full DD of the old SNL, but in storage 100 miles away. Still worth

  • Accuracy of Verizon Speed Test

    I am wondering about the accuracy of the Verizon speed test.  I have the 75/35 service and I am testing today around 10/15 on several test sites...except Verizon. The Verizon site, in the past and today, ALWAYS tells me the speed is what it is suppos

  • After Extracting

    Hi all, I am so stuck and it will no doubt be something very simple, however my problem is: After extracting an image from it's original background, the background surrounding the image is now transparent I want to then move my extraction onto anothe

  • Strange FWSM log message

    Dear expects, I have a strange problem with a FWSM on Catalyst 6509, this funny logging message keep generating on the FWSM %FWSM-3-106011: Deny inbound (No xlate) icmp src fwsm_212:10.10.212.30 dst fwsm_212:10.10.212.14 (type 8, code 0) %FWSM-3-1060