Java -- excel

Hi
I have to read excel document from java program. I have tried using following code
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:xml33", "", "" );
stmnt = c.createStatement();
String query = "select * from [software$];";
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() ){
for some reason it reads only upto some records and leaves out the rest.I have observed that It is reading in nearly 4k chunks i.e if I have 17k file i think it is reading data upto 16k and leaves the last 1k. similarly a 5k file reads 4k and leaves out last 1k (numbers are approx but the fact is I am losing data at the end) Any Idea where I am wrong.
Thanks

You could try POI at www.apache.org. It doesn't need the odbc driver stuff.

Similar Messages

  • Java-Excel program not working

    Hi,
    Can anyone Help me?
    Below is a small code snippet i used to read an excel file using the POI-HSSF API
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import java.io.FileInputStream;
    * This is a sample to Read an  Excel Sheet using
    * Jakarta POI API
    * @author  Elango Sundaram
    * @version 1.0
    public class ReadXL {
        /** Location where the Excel has to be read from. Note the forward Slash */
        public static String fileToBeRead="Read.xls";
        public static void main(String argv[]){      
            try{
                    System.out.println("hai");
                        // Create a work book reference
                        HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(fileToBeRead));
                        // Refer to the sheet. Put the Name of the sheet to be referred from
                        // Alternative you can also refer the sheet by index using getSheetAt(int index)
                        HSSFSheet sheet = workbook.getSheet("Sheet1");
                        //Reading the TOP LEFT CELL
                        HSSFRow row = sheet.getRow(0);
                        // Create a cell ate index zero ( Top Left)
                        HSSFCell cell = row.getCell((short)0);
                        // Type the content
                        //System.out.println("THE TOP LEFT CELL--> " + cell.getStringCellValue());           
            }catch(Exception e) {
                System.out.println("!! Bang !! xlRead() : " + e );
    }I have compiled in JAVA 1.5.0_09 under Solaris 5.10 platform
    $ javac -cp poi-3.0.1-FINAL-20070705.jar  -Xlint:deprecation ReadXL.java
    $ java ReadXL
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbookHow to proceed???

    You need to add the directory where the ReadXL class is located.
    java -cp .:poi-3.0.1-FINAL-20070705.jar ReadXLMessage was edited by:
    RealHowTo

  • Jre 1.4.2_12 + java excel api problem.

    I got problem when i write a program to read chinese excel sheet with jre 1.4.2_12, chinese will encoding incorrect in java, but when I change jre version to jre 1.4.2_10 or jre 1.5.0 update 7 , everything s ok . any solution?
    p.s. jexcelapi 2.5.8

    I got problem when i write a program to read chinese
    excel sheet with jre 1.4.2_12, chinese will encoding
    incorrect in java, but when I change jre version to
    jre 1.4.2_10 or jre 1.5.0 update 7 , everything s ok
    . any solution?
    p.s. jexcelapi 2.5.8Hi Vencent,
    I am also seeing encoding problems with 1.4.2_12 and havent been able to find a solution. Did you find a solution to your problem? If so I'd appreciate it if you could post it.
    Thanks,
    Declan.

  • Java/Excel interface

    Hello everybody!!
    I am doing an MSc Dissertation at the moment and was wondering if anyone could tell me how to get a tab delimited text file and use Java to create it in to an Excel spreadsheet format?
    This new spreadsheet will then need to be modifyed to supply new information, which may then be displayed as charts.
    Any help appreciated,
    Kenny..

    Excel understands tab-delimited text anyway. Why would you want to get Java to change it at all?
    Anyway, search Javaworld for "Excel" - they've run articles on various technologies for playing around with Excel files.
    http://www.javaworld.com
    I don't think there's much out there that will help you do charts or formulae with Excel through Java. The only route that I know for doing that is using a messy Java-COM bridge (and that requires opening up Excel). It'll depend what you hope to achieve.
    Hope this helps.

  • Java Excel Add-In?

    I am doing alot of work with Excel right now and I have explored with creating custom macros to make my life easier. However, the macros are created with VBA and I have no experience in it and I have found extremely little help online.
    I wanted to know if there was an add-in or something for Excel that allowed macros to be coded in java.
    I have used JExcel, but that isnt what I'm looking for. I'm wanting to be able to create instances of code while in excel to be used then and there.
    Any help is appreciated.

    Aussiemcgr wrote:
    I am doing alot of work with Excel right now and I have explored with creating custom macros to make my life easier. However, the macros are created with VBA and I have no experience in it and I have found extremely little help online. I have "dabbled" quite a bit into Excel VBA macros, and, truth be told, found a plethora of "help online". There is a fair amount of dross, as well, but a lot of nuggets can be sifted out, it seems to be that you are either not searching, or are upset that you don't find complete cut-n-paste code answers for everything you want.

  • Java - Excel communication

    hi all,
    I am new to Java. I am looking for some information regarding how to communicate between java and Excel. I've tried the Java active x bridge and it is not very scalable, getting several issues. I am not sure whether that is the right way to go. Some one suggested to have Java - Com direct communication and I 've no idea where to start. If you know about this, could you please share?.
    please email to [email protected]
    Thanks,
    kris

    Hi scsi-boy,
    I'm trying to help him out. I'm not spam the forum.
    I gave him an option and a detailed example that he
    can follow to slove his problem. I didn't see
    anything wrong about this.
    Have a nice day.
    Hao Zhang
    J-Integra Interoperability Solutions
    http://j-integra.intrinsyc.com/
    high performance interop middleware for java, corba,
    com & .netHoa Zhang,
    Oh yeah you really wanted to help. That's why you put your advertisement for your crap into a thread that was SEVEN MONTHS OLD.
    No I don't believe you. I believe you are liar. I believe you and your associates search for old posts to post your advertising into.
    That is spam. And from this account and the other jintegra ones this has been going on for some time. This is spam and an abuse of the forum and has been reported as such. The other account also was an abuse because there were two or three different people using it to post your jintegra ads into very old posts.
    It is one thing to mention something that may help in a topical thread. But when the thread is old like this you are NOT doing it to help. You are doing it to advertise. And don't think anybody is so stupid as to not see or understand the difference.
    And just to be clear since you people won't stop as well as reporting abuse I will be posting my jintegra is a dirty spammer company message in every one of these style posts I see from now on to warn any unsuspecting individuals about your conniving behaviour.
    You have a good day now too. It will be better if you and your associates drop your little campaign now.
    Sincerely,
    Max

  • Jakarta POI and Java Excel API

    I recently downloaded both these as I'm trying to create an application that reads information from an excel file. However, the problem I am having is that I just don't know where to start. When I download the files and unzip them, I haven't a clue where to put the files or how to call them from my java files. I've read the help files on both the websites but am no clearer on what to do. Any help would be much appreciated.

    Download an IDE like Eclipse or JBuilder. Set-up the POI or JExcel JAR files on your new project's class path. Import the relevant packages into the class that will use them. Start typing, autocomplete will help give you a list of classes and methods that are available.
    If the above is confusing, start over. Go back and re-read how to import external JAR's onto a classpath. Try to use another third-party API to get the hang of it. Then, do it with POI. Follow the examples, even copy-paste a class into your own source tree and try to compile. Gradually, build up your expertise. Now, go to the Javadocs. You should have the ability to use any class or method published in the API.
    - Saish

  • Java Excel connection

    Hi everybody,
    Can anybody plz help me with the following problem.
    I have an application , which can be used for importing datas from any type of file.
    At present ,I want to import datas from any excel sheet. So i want to know how to create the DSN programmatically for Excel files. or else without creating a DSN how can i read an Excel file.
    Can anybody plz share me how can i do it. It is very urgent for me.
    thanks in advance
    Rose

    Look into either JExcel or Jakarta's POI. Both read Excel files into Java.
    - Saish

  • JAVA & EXCEL using the POI API

    Hi,
    I presently have a stand alone application that I need to redesign for a future use of excel.
    I created a spreadsheet with the following cell value:
    B5 = 1st value
    B6 = second value
    B9 = final value
    B11 is the total : SUM(B5:B9)
    My code is:
    try {
    // Connect to the Excell workbook
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("testjava.xls"));
    HSSFWorkBook wb = new HSSFWorkbook(fs);
    // Choose the sheet object
    HSSFSheet sheet = wb.getSheetAt(0); // or use .getSheet("test");
    // Create the row object
    HSSFRow rowMonday = sheet.getRow(4);
    HSSFRow rowTuesday = sheet.getRow(5);
    HSSFRow rowWednesday = sheet.getRow(6);
    HSSFRow rowThursday = sheet.getRow(7);
    HSSFRow rowFriday = sheet.getRow(8);
    HSSFRow rowTotal = sheet.getRow(10);
    // Get the week value
    A5 = rowMonday.getCell((short)0);
    B5 = rowMonday.getCell((short)1);
    A6 = rowTuesday.getCell((short)0);
    B6 = rowTuesday.getCell((short)1);
    A7 = rowWednesday.getCell((short)0);
    B7 = rowWednesday.getCell((short)1);
    A8 = rowThursday.getCell((short)0);
    B8 = rowThursday.getCell((short)1);
    A9 = rowFriday.getCell((short)0);
    B9 = rowFriday.getCell((short)1);
    // Get the total value
    A11 = rowTotal.getCell((short)0);
    B11 = rowTotal.getCell((short)1);
    } catch ( IOException ex ) {
    ex.printStackTrace();
    System.out.println(ex);
    Here is my get method:
    public double getCellB11()
    this.dblTotal = this.B11.getNumericCellValue();
    return this.dblTotal;
    My application is a simple application with 7 JLabels and 7 JTextField and a getValue and a calculate JButton.
    the getValue button get the right value, the total is wrong it keep the value at the first run time.
    when I use the calculate button, the spreadsheet is updated with the new value, the total is right in the spreadsheet. But in my application the total still the same value at the first run time. It seems like if the value does not refresh itself.
    Here is the code fof the get and calculate methode in my application:
    if (object == butGetValue) {
    txtName.setText(ToExcel.getCellB3());
    txtMonday.setText(String.valueOf(ToExcel.getCellB5()));
    txtTuesday.setText(String.valueOf(ToExcel.getCellB6()));
    txtWednesday.setText(String.valueOf(ToExcel.getCellB7()));
    txtThursday.setText(String.valueOf(ToExcel.getCellB8()));
    txtFriday.setText(String.valueOf(ToExcel.getCellB9()));
    txtTotal.setText(String.valueOf(ToExcel.getCellB11()));
    if (object == butCalculate) {
    ToExcel.setCellB3(txtName.getText());
    ToExcel.setCellB5(Double.parseDouble(txtMonday.getText()));
    ToExcel.setCellB6(Double.parseDouble(txtTuesday.getText()));
    ToExcel.setCellB7(Double.parseDouble(txtWednesday.getText()));
    ToExcel.setCellB8(Double.parseDouble(txtThursday.getText()));
    ToExcel.setCellB9(Double.parseDouble(txtFriday.getText()));
    ToExcel.writeNewValue();
    txtTotal.setText(String.valueOf(ToExcell.getCellB11()));
    Is there anyone who can help me with this?
    Any help would be appreciate.

    That's native OS problem. Once excel opened a file(even for reading) you can't write to it using other program like your servlet. So close the file before writing, or simply write to different file name.

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to read the data from an excel file into MYSQL by java language

    Hi all,
    I have some data in excel spread sheet and I want to put the data into MYSQL data base. I created the tables in MYSQL> How can I write a program in JAVA that puts the value from excel sheet to mysql??
    I would appreciate your help
    regards

    By typing code at the keyboard... but presumably you meant to ask what code you should type.
    To get data out of Excel there are a few alternatives. The Google keywords I would use to find them are "java excel". I use Apache POI but there are other possibilities, I believe. As for getting the data into MySQL once you have extracted it from Excel, you would use JDBC. But you already knew that, didn't you? You did find the JDBC forum.
    In general it's better to ask a specific question on a forum. If you don't have a clue (which is the way we all start out) then just telling people that isn't going to be helpful. The best you're going to get is links to tutorials, which you could perfectly well have found for yourself by simple web searches.

  • NEW Excel Read/Write Lib for JAVA

    FastExcel is a pure java excel read/write component.It's FAST and TINY. provide:
    * Reading and Writing support for Excel '97(-2003) (BIFF8) file format.
    * Low level structures for BIFF(Binary Interchange File Format).
    * Low level structures for compound document file format (also known as "OLE2 storage file format" or "Microsoft Office compatible storage file format").
    * API for creating, reading excel file.
    website http://fastexcel.sourceforge.net/
    Edited by: guooscar on Jun 18, 2009 7:44 PM

    guooscar wrote:
    cotton.m wrote:
    guooscar wrote:
    I read almost all of jxl source code and i try to use it to export/import data the result is slow,OOM,that’s allOkay, fair enough.= _ =|||?
    At best this is a pretty specialized tool right? I mean 300,000,000 rows of data imported or exported (and I'm not sure which) daily from/to Excel is a bit of a wtf.
    But without formula support... it's sort of like the difference between a SAX and DOM parser.

  • Manejar archivos de excel desde Java

    Hola, necesito hacer un programa y manejar algunos datos, para ello tengo planeado utilizar excel ya que el cliente que requiere el programa que hare utilizaba ese formato para almacenar información. Sucede que no estoy muy convencido por las librerias para manejar archivos de excel, que son POI y JExcel, cuales son las ventajas-desventajas de cada uno y cual recomiendan? ME interesa usar este formato por que dudo que el cliente pueda conseguir access o SQL. Y algunos consejos que den para manejar la informacion?

    You should ask questions in English here. Not much chance for an answer in Spanish.
    Anyway, does this have anything to do with Oracle Reports? I see Java, Excel, no Reports.

  • Import data from excel/csv file in web dynpro

    Hi All,
    I need to populate a WD table by first importing a excel/CSV file thru web dynpro screen and then reading thru the file.Am using FileUpload element from NW04s.
    How can I read/import data from excel / csv file in web dynpro table context?
    Any help is appreciated.
    Thanks a lot
    Aakash

    Hi,
    Here are the basic steps needed to read data from excel spreadsheet using the Java Excel API(jExcel API).
    jExcel API can read a spreadsheet from a file stored on the local file system or from some input stream, ideally the following should be the steps while reading:
    Create a workbook from a file on the local file system, as illustrated in the following code fragment:
              import java.io.File;
              import java.util.Date;
              import jxl.*;
             Workbook workbook = Workbook.getWorkbook(new File("test.xls"));
    On getting access to the worksheet, once can use the following code piece to access  individual sheets. These are zero indexed - the first sheet being 0, the  second sheet being 1, and so on. (You can also use the API to retrieve a sheet by name).
              Sheet sheet = workbook.getSheet(0);
    After getting the sheet, you can retrieve the cell's contents as a string by using the convenience method getContents(). In the example code below, A1 is a text cell, B2 is numerical value and C2 is a date. The contents of these cells may be accessed as follows
    Cell a1 = sheet.getCell(0,0);
    Cell b2 = sheet.getCell(1,1);
    Cell c2 = sheet.getCell(2,1);
    String a1 = a1.getContents();
    String b2 = b2.getContents();
    String c2 = c2.getContents();
    // perform operations on strings
    However in case we need to access the cell's contents as the exact data type ie. as a numerical value or as a date, then the retrieved Cell must be cast to the correct type and the appropriate methods called. The code piece given below illustrates how JExcelApi may be used to retrieve a genuine java double and java.util.Date object from an Excel spreadsheet. For completeness the label is also cast to it's correct type. The code snippet also illustrates how to verify that cell is of the expected type - this can be useful when performing validations on the spreadsheet for presence of correct datatypes in the spreadsheet.
      String a1 = null;
      Double b2 = 0;
      Date c2 = null;
                        Cell a1 = sheet.getCell(0,0);
                        Cell b2 = sheet.getCell(1,1);
                        Cell c2 = sheet.getCell(2,1);
                        if (a1.getType() == CellType.LABEL)
                           LabelCell lc = (LabelCell) a1;
                           stringa1 = lc.getString();
                         if (b2.getType() == CellType.NUMBER)
                           NumberCell nc = (NumberCell) b2;
                           numberb2 = nc.getValue();
                          if (c2.getType() == CellType.DATE)
                            DateCell dc = (DateCell) c2;
                            datec2 = dc.getDate();
                           // operate on dates and doubles
    It is recommended to, use the close()  method (as in the code piece below)   when you are done with processing all the cells.This frees up any allocated memory used when reading spreadsheets and is particularly important when reading large spreadsheets.              
              // Finished - close the workbook and free up memory
              workbook.close();
    The API class files are availble in the 'jxl.jar', which is available for download.
    Regards
    Raghu

  • Error While reading an Excel file from KM Folder.

    Hi Guru's,
    In my PDK Application I am trying to read an Excel file from KM Folder.
    Workbook workbook = Workbook.getWorkbook(new File("/irj/go/km/docs/documents/test/Test.xls"));
    It gives an error:
    Error:java.io.FileNotFoundException: \irj\go\km\docs\documents\test\Test.xls (The system cannot find the path specified)
    Details of appli:
    In my JspDynpage I am calling a utility Java file.
    There I have to read an  Excel and to passit to JSP.
    Details of jar files  used:
      jxl-2.6
      com.sap.security.api.jar
    Regards,
    Ram

    Hi,
    You are trying to read file wrong way. In the tutorial of Java Excel Api: "JExcelApi can read an Excel spreadsheet from a file stored on the local filesystem or from some input stream.". You are trying to read from file system. So you must get file input stream then you can read it. Please search forums KM file read.

Maybe you are looking for

  • Premiere 7.2.1 strange artifacts

    I have these strange artifacts in several files, with latest premiere cc version (see images): artifacts appear in premiere as well as in after effects, but they are not visible if same file is opened in bridge (or VLC player). These files are .mov e

  • Sound stops when set flash obj visibility to false on IE

    How can I prevent sound from stopping on IE when I set a flash <object> visibility to false, through javascript ? i.e.: document.getElementById('flashObj').style.visibility = 'false'; All other web browsers behave normally (they just hide the player,

  • Safari shutting down because of UltraMPto.so plugin. Help!

    Every 20 minutes or so safari is unexepectedly quitting because of a plugin called UltraMPto.so. I don't know where this plugin came from. PLEASE HELP. It is very frusterating:( Here is the message that I receive: rocess:         Safari [376] Path:  

  • Stop automatic use of bluetooth?

    I finally have the bluetooth hooked up so I can drive with it-thanks to the Verizon store people (and a 1 hr wait because they forgot me.  At least I had work to read). Now I can't answer my phone unless I use the bluetooth.  I'm not one who will be

  • Browser closing when opening PDF output in Apps

    Hello, When opening the concurrent request/report output (for PDF output), the browser just closes. The PDF output were generated thru XML Publisher (reports converted in XML Publisher - rtf). PDF is defined in the Viewer Options/ System Options(View