How to read from MS  Excel file ?

Which is the best way to read from a MS Excel file ?
I need to read both "column-wise" and "row-wise".
Is there any free software or java api which does this. I have come across some paid softwares which do that, but i would prefer using something which is free.
I have tried using the "save as" option to save as tab delimited, comma delimited, unicode text ... but they raise too many exceptions, and cannot be read as we read a normal text file.
Please do suggest.
Thanks.

http://forum.java.sun.com/thread.jsp?forum=31&thread=289935
http://forum.java.sun.com/thread.jsp?forum=4&thread=285062
If you would search of the forums, you would find these two threads, and probably many others. They not only include pointers to what you ask but discussions of the pros and cons among various solutions.
/Mel

Similar Messages

  • Reading from an excel file

    I was wondering, what do i need to look at to get cracking with making a programme that can read from a excel file
    I was thinking of making a programme that uses a excel spreadsheet <this spreadsheet is made and provided by the national lottery and has all the winning combinations that have been drawn in past draws> and reading them in and generating a list of combinations that have not occured yet
    Its just for a bit of fun, but could be a good challenege
    thanks

    PaulOckleford wrote:
    If all you want to do is select from the excel sheet you may find it easier to use the jdbc option, I have an example of some code I wrote that does a select from an excel sheet and it may be useful for you:Just my opinion here but I would avoid using odbc to deal with the spreadsheet if at all possible.
    Time for a war story:
    After losing an argument with some business, marketng and management I had to develop a program that accepted spreadsheets as datafiles and it was nothing but trouble.
    I experienced all kinds of type problems, the most common and annoying of them being
    that the driver (via some logic unknown to me) will determine the type of each column.
    Any data that is does not match that expectation is dropped (I found that the query returned NULL).
    As far as I could tell there was no way to make the driver treat the data the way you want it too.
    After much trouble and lots of manual intervention by the poor person who has to deal with this data on a regular basis it seems to be working but it was not fun it is still very ugly code.
    You may not end up reliving my tale of woe, but I though I would give you some fair warning.
    As I continue to say "Spreadsheets are not a reasonable data transfer format."

  • How to read from a text file one character at a time?

    Hello
    I wish to read from a text file in a for loop and that on every iteration i read one charachter and proceed to the next one.
    can anyone help me?
    Lavi 

    lava wrote:
    I wish to read from a text file in a for loop and that on every iteration i read one charachter and proceed to the next one.
    can anyone help me?
    Some additional comments:
    You really don't want to read any file one character at a time, because it is highly inefficient. More typically, you read the entire file into memory with one operation (or at least a large chunk, if the file is gigantic) and then do the rest of the operations in memory.  One easy way to analyze it one byte at a time would be to use "string to byte array" and then autoindex into a FOR loop, for example.
    Of course you could also read the file directly as a U8 array instead of a string.
    Message Edited by altenbach on 06-10-2008 08:57 AM
    LabVIEW Champion . Do more with less code and in less time .

  • How to read Multiple sheet Excel file( One of the sheet generated by rule )

    Hi Folks,
    I have one critical requirement about reading an Excelsheet.
    I have an Excelsheet, which has got 2 tabs. Now  TAB1  is having the data stored and TAB2 has got data, which is created by some Rule using in Excelsheet.
    Now when i am trying to pass this Excel sheet to Function module ' TEXT_CONVERT_XLS_TO_SAP'  this Fucntion Module is returning the data from TAB1. But my requirement is that, i have to read data from TAB2, which is generated by implementing some rule on TAB1.
    So Please help, me how can i read the multiple sheet Excel document and how to read the tab , which is generated by some rule.
    Thanks.
    PG

    Hi Guru,
    Thanks for your reply.
    I have seen this blog, and treid to implement the code. But when i am caaling method GET_RANGES_DATA
    in the program, it's hanging my whole program and followed by hanging my SAP login.
    I have no clue, why my program is getting hung up, bcoz of this call.
    After debugging this method, i found that the program is getting hung up at call of one function module DP_GET_TABLE.
    This Function Module is internally called by above menthioned method.
    So please let me know, if you have some input on above issue, or if you know some other way to implement this problem.
    Regards
    PG

  • How to read from a xml file(in String format) using a java program

    hi friends
    i have a string , which is xml format. i want read the values and display it.can any one suggest how to read a xml file of string format using a javaprogram
    thanks

            final DocumentBuilder db =  DocumentBuilderFactory.newInstance().newDocumentBuilder();      
            final InputStream documentStream = new ByteArrayInputStream(documentXMLSourceString.getBytes("utf-8"));
            final Document document = db.parse(documentStream);

  • How to read from 2 data files ?

    Hi,
    I'm trying to create a program that will read data from two dat files that are linked by a reference code in each file.
    I have been using StringTokenizer to read from one file as follows:
    but the problem is that the dat files contain int, String and double values.
    import java.io.*;
    import java.util.StringTokenizer;
    public class Student
         public static void main(String[]args)
         String file = "CourseWork.dat";//Locate the file to open
         String input;     // to be used to identify each line of text
         String word;     // used to identify each word in the text
         StringTokenizer tokenizer;//value of StringTokenizer
         BufferedReader fin = Text.open(file);
         input = fin.readLine;          
         while (input !=null)          
                   tokenizer = new StringTokenizer (input);
                   while (tokenizer.hasMoreTokens())                {                                                                                               word = tokenizer.nextToken();
                   System.out.println(input);
                   input = fin.readLine();
    Any pointers greatly appreciated

    read all of them to a StringBuffer,
    then stoken.
    peter
    Pivotonic Inc. http://www.pivotonic.com
    1. java IDE tool : JawaBeginer
    2. java jar tool : JavaJar
    -----------------------------

  • How to read from a .properties file...?

    Hello all,
    I'm new to this forum.
    I have a problem in reading data from .properties file...
    Follow is my properties file...
    log4j.properties
    log4j.rootLogger=warn, file, mail
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.maxFileSize=100KB
    log4j.appender.file.maxBackupIndex=5
    log4j.appender.file.File=D:\log.txt
    log4j.appender.file.threshold=info
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
    #email appender
    log4j.appender.mail=org.apache.log4j.net.SMTPAppender
    #defines how othen emails are send
    log4j.appender.mail.BufferSize=1
    log4j.appender.mail.SMTPHost="smtp.Honeywell.com"
    log4j.appender.mail.From=[email protected]
    log4j.appender.mail.To=[email protected]
    log4j.appender.mail.Subject=Log ...
    log4j.appender.mail.threshold=error
    log4j.appender.mail.layout=org.apache.log4j.PatternLayout
    log4j.appender.mail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
    I want to access file path given in .properties file..
    I'm coding like this...
    Properties props = new Properties();
    String p=props.getProperty("file.FILE");
    The above code is not getting me the string.. it shows null value...
    Any solution...?
    Thanks in advance......

    RahulSharna wrote:
    public Properties getProperties(String fileName)throws Exception{
    Properties prop = null;
    FileInputStream fis = null;
    Exception e = null;
    File file = new File(fileName);
    if(!file.exists())
    new FileNotFoundException(fileName);
    try{
    prop = new Properties();
    fis = new FileInputStream(file);
    prop.load(fis);
    }catch(Exception exp){
    e = exp;
    }finally{
    if(fis != null){try{fis.close();}catch(Exception ep){}}
    fis = null;
    file = null;
    if(e != null)
    throw e;
    return prop;
    }Hope the above snippet helps :)
    REGARDS,
    RaHuLYou do know that you can throw out of the catch block without "short-circuiting" the finally block, right? Making the declaration of e completely foolish. (Unless you actually want to do something after the try/catch block, of course.) And, if all you're going to do is throw the exception anyway, why bother catching it?

  • How to read from text file?

    I would like to read data (frequencies) already written in a text file. I will need read these frequencies one at a time to set the function generator (as part of my data acquisition application), acquire data that is in turn written to a file and then go back and read the next frequency from the file to repeat the process again. I also have another idea of doing the same, which is read all the frequencies from the text file and populate a table and a frequency value is picked from the table each time to go through the process mentioned above.
    Can anyone suggest the following: (1) How to read from a text file, (2) What could be the most efficient way of solving my above problem.
    I am a new LabVIEW user and any help will be appreciated.

    Hi Research,
    Depending on the format of the data file, there are a few options for reading it.  If it is tab delimited, you may want to use the Read from SpreadSheet File VI which will read the file into an Array.  You can then use the Index Array VI to pull out individual entries.  If the files is ASCII but not tab delimited, you could use the regular Open File and Read File VIs.  You can either read the file out piece by piece, or read the entire file into a string and then use the Match Pattern VI to parse out the different elements (there are actually many ways to do this - check out the Strings subpalette). 
    Since you're new to LabVIEW, you may want to check out these resources:
    Three Hour Introduction to LabVIEW
    Six Hour Introduction to LabVIEW
    Getting Started with LabVIEW
    I hope this helps!  Let us know if you have more questions,
    Megan B.
    National Instruments

  • Help! How to read data from an Excel file?

    Hi,
    I need to read data from an Excel file that may contain more then one table in a sheet. How can I read them?
    I would be eternally grateful to anyone who can give me any information.

    Did you try POI from Apache?
    http://jakarta.apache.org/poi/index.html

  • How can i Read the Data from such Excel files?

    Dear All,
            Here I am attaching an excel file in which all the datat cells have more than one data, can anybody tell me, how to read from such kind of excel files?
    Thanks in Advance & Happy New Year,
    Rujuta

    Greetings Ruju,
    Here is what I do to read such a file:
    I first save the Excel file (xls) as CSV file (which is easier to handle: Comma Seperated Values) .. Open the file using Excel and save it CSV.
    Then using the code attached I get all these values in a string array.
    Hope this helps
    Ayman Mohammad Metwally
    Automation Engineer
    Egypt - Cairo
    Attachments:
    CSV2ARRAY.vi ‏29 KB

  • How to read data from the excel file using java code.

    Hi to all,
    I am using below code to getting the data from the excel file but I can't get the corresponding data from the specific file. can anyone give me the correct code to do that... I will waiting for your usefull reply......
    advance thanks....
    import java.io.*;
    import java.sql.*;
        public class sample{
                 public static void main(String[] args){
                      Connection connection = null;
                          try{
                               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                               Connection con = DriverManager.getConnection( "jdbc:odbc:Mydsn","","" );
                               Statement st = con.createStatement();
                               ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
                               System.out.println("sample:"+rs);
                                  ResultSetMetaData rsmd = rs.getMetaData();
                                  System.out.println("samplersd:"+rsmd);
                               int numberOfColumns = rsmd.getColumnCount();
                                  System.out.println("numberOfColumns:"+numberOfColumns);
                                   while (rs.next()) {
                                            System.out.println("sample1:"+rs);
                                            for (int i = 1; i <= numberOfColumns; i++) {
                                                 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());
                        }

    1: What is the name of the excel sheet?
    2: What is printed in this program? null ? anything?
    error?Excel file name is "sample.xls" I set excel file connectivity in my JDBC driver(DSN). Here in my program I am not giving that excel file name. I am giving only that excel sheet name. that is followed
    ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );The output of this program is given bellow.
    sample:sun.jdbc.odbc.JdbcOdbcResultSet@1b67f74
    samplersd:sun.jdbc.odbc.JdbcOdbcResultSetMetaData@530daa
    numberOfColumns:2

  • How to retrieve data from an Excel file which is located on server

    hi everybody,
                    I am using SAP NWDS 2004s .     
                I have done an application on how to export the table data into an Excel .
    Now i want to get the data from an Excel file which is located in server and display that data which is in excel in a View for example a Sample view in Webdynpro  .
    In Sample view i took a uielement textview to display the data ....   
    can any one help how to procced further
    Thanks in advance
    Madhavi

    Options to read Excel data to WebDynpro context
    Reading Excel Sheet from Java without using any Framework
    Reading Multiple Sheets of Excel Sheet from Java
    Few Threads
    How to Display the content of Excel file into Webdynpro Table
    Is it possible to upload data from excel file(.xls)
    Re: How to export the data as integer into excel sheet?
    regards
       Vinod

  • Reading data in excel files from client side

    Hello Experts,
    I want to build a website from which clients can upload data in the excel sheets they have into the sql server 2000 on the database server.
    These excel files will be at the client machine from where they will upload all the data from the excel file to database server through this website.
    Can you please help how to go about doing this.

    There are two open source projects that will help you out: Jakarta POI and JExcel. Both can serialize and deserialize Excel files to Java. You can also use the older ODBC-JDBC bridge, which can both read Excel files (albeit in a limited way with SQL syntax) and then output to your SQL Server.
    - Saish

  • HOW TO WRITE AND READ FROM A TEXT FILE???

    How can I read from a text file and then display the contents in a JTextArea??????
    Also how can I write the contents of a JTextArea to a text file.
    Extra Question::::::: Is it possible to write records to a text file. If you have not idea what I am talking about then ignore it.
    Manny thanks,
    your help is much appreciated though you don't know it!

    Do 3 things.
    -- Look through the API at the java.io package.
    -- Search previous posts for "read write from text file"
    -- Search java.sun.com for information on the java.io package.
    That should clear just about everything up. If you have more specific problems, feel free to come back and post them.

  • How can I create multiple QR Codes from an Excel File?

    Hi there,
    I am currently trying to set up business cards with a QR Code on the back of each card. Therefore I have an excel spreadsheet, which contains all the data necessary for the business card like name, function, e-mail adress,... the data is then filled in automatically by using the standard function with tags for each column (e.g. table column name is filled in as <<name>> in the specific location on the business card and once executed it is matched with the data from the excel file).
    Is there anything which could help me to automate the personalization of the QR Codes?
    All the best

    For free? Not at the moment. CC does have the ability to create QR codes but only one at a time. In CS6 (perhaps earlier versions?), regular poster/advanced scripter Jongware devised a script to prepare a QR code but again, could only do one at a time.
    However, someone did build on Jongware's QR code to do this from an InDesign file that had the necessary information in tagged text boxes and would prepare QR codes accordingly. However, it would leave them in the InDesign file (e.g. not separate EPS/PDFs).
    So, a long workaround would be:
    install the script and read the thread on the adobe forums (jongware's QR code plus the additional improvement): http://forums.adobe.com/message/4787823#4787823
    data merge the current data into the indesign file using the similar structure as the fourth poster in that post had written
    once all the QR codes are written, create a PDF of the file and then use one of various methods to break up the PDF into single page files: http://colecandoo.wordpress.com/2013/07/13/breaking-up-is-hard-to-do-indesign-files-into-i ndividual-pdfs-that-is/
    It's a lot of work to generate multiple QR codes. A paid solution offered by either Meadows DPS or Woodwing (two companies I have no affiliation with whatsoever) or any other plug-in provider for that matter: http://www.adobe.com/products/indesign/indepth.displayTab3.html may be an alternative that is worth pursuing.

Maybe you are looking for

  • IPOD NANO compatible with Windows Media Player????

    Hey guys, I realize this may be a really dumb posting but I'm looking at purchasing a iPod Nano but my concerns are about how you load your music onto the ipod. I currently have all my music in my Windows Media Player but the ipod webiste says that I

  • Lost mail rules when upgrading to ML, can't restore from time machine

    Hi, I've installed mountain lion and restored from time machine and mail rules were not there. There's only news from apple. I tried to restore the rules myself (MessageRules.plist and MessageRules.plist.backup) but when opening mail rules were not t

  • Planned delivery time issue

    Hello Experts, We have below requirement. Created sales order for a particular material. Planned delivery time is picked from info record for that material and PR has been created. We are converting PR into PO and the planned delivery time is fine. N

  • System Center TechNet Guru News: October Winners Announced

    All the votes are in!  And below are the results for the TechNet Guru Awards, October 2014 !!!! For a full list of winners, see the full blog post, as runners up had to be removed from this post to fit the forum max length restrictions.  BizTalk Tech

  • Can one include footnotes in a blog?

    I used to include footnotes in my blog but Word has now stopped doing blogs and I cannot find an easy way to continue using the footnotes simply using dreamweaver cs6 which I have done for 2 years. Is it possible? David B