Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Read Excel File into JTable

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Read Excel File into JTable

    please i need help in getting excel file into jtable

    i'm searching for this problem for 1 weak and no results

    i downloaded hssf packages and didn't make achange in reading...

    Thanks


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Read Excel File into JTable

    please i need help in getting excel file into jtable
    a) Read the excel file into a data structure b) display data structure in JTable. If you have a specific question about either of these steps, then please post what you've tried (as an SSCCE), where you are stuck, and please post any and all errors or misbehavior.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Read Excel File into JTable

    this code give me an error in this line :
    w = Workbook.getWorkbook(inputWorkbook);


    PHP Code:
    import java.io.File;
    import java.io.IOException;

    import jxl.Cell;
    import jxl.CellType;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;

    public class 
    ReadExcel {

      private 
    String inputFile;

      public 
    void setInputFile(String inputFile) {
        
    this.inputFile inputFile;
      }

      public 
    void read() throws IOException  {
        
    File inputWorkbook = new File(inputFile);
        
    Workbook w;
        try {
          
    Workbook.getWorkbook(inputWorkbook);
          
    // Get the first sheet
          
    Sheet sheet w.getSheet(0);
          
    // Loop over first 10 column and lines

          
    for (int j 0sheet.getColumns(); j++) {
            for (
    int i 0sheet.getRows(); i++) {
              
    Cell cell sheet.getCell(ji);
              
    CellType type cell.getType();
              if (
    type == CellType.LABEL) {
                
    System.out.println("I got a label "
                    
    cell.getContents());
              }

              if (
    type == CellType.NUMBER) {
                
    System.out.println("I got a number "
                    
    cell.getContents());
              }

            }
          }
        } catch (
    BiffException e) {
          
    e.printStackTrace();
        }
      }

      public static 
    void main(String[] argsthrows IOException {
        
    ReadExcel test = new ReadExcel();
        
    test.setInputFile("c:/Age.xls");
        
    test.read();
      }



  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Read Excel File into JTable

    this code give me an error in this line :
    What error? We can only guess - compile time? Runtime? Post it in its entirety

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    17
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Read Excel File into JTable

    thanks for your effort

    i get the error ...

    the file extends must be just 1997-2003

Similar Threads

  1. How to read excel in java ??
    By vashist13 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 22nd, 2013, 02:03 PM
  2. read excel sheet into database
    By shri in forum JDBC & Databases
    Replies: 7
    Last Post: March 8th, 2013, 12:51 AM
  3. Remove JTable row that read txt file records
    By sajjad4563 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 30th, 2012, 02:22 PM
  4. convert excel to xml and read the input from xml file
    By rahulruns in forum Object Oriented Programming
    Replies: 5
    Last Post: April 3rd, 2012, 11:13 AM
  5. Read excel file
    By chamil in forum JDBC & Databases
    Replies: 1
    Last Post: October 25th, 2010, 03:00 AM