Read Excel Sheet

Reply

Join Date: Apr 2009
Posts: 3
Reputation: sneharaveendran is an unknown quantity at this point 
Solved Threads: 0
sneharaveendran sneharaveendran is offline Offline
Newbie Poster

Read Excel Sheet

 
0
  #1
May 26th, 2009
Hi all I need to read an Excel sheet using java and I need to know how many columns are there in that excel sheet. Please drop a code snippet to this thread
Last edited by sneharaveendran; May 26th, 2009 at 7:09 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Read Excel Sheet

 
0
  #2
May 26th, 2009
Originally Posted by sneharaveendran View Post
Hi all I need to read an Excel sheet using java and I need to know how many columns are there in that excel sheet. Please drop a code snippet to this thread
Don't ask lamely for ready-made code snippets no one's going to give you that.

If you are ready to do something for your self take a look here : http://poi.apache.org/
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 13
Reputation: jaka.ramdani is an unknown quantity at this point 
Solved Threads: 2
jaka.ramdani jaka.ramdani is offline Offline
Newbie Poster

Re: Read Excel Sheet

 
-1
  #3
May 26th, 2009
Originally Posted by sneharaveendran View Post
Hi all I need to read an Excel sheet using java and I need to know how many columns are there in that excel sheet. Please drop a code snippet to this thread
Try using JXL. Below some simple approach for getting total rows and columns of a Worksheet in an Excel file.
  1. import java.io.File;
  2. import java.io.IOException;
  3. import java.util.logging.Level;
  4. import java.util.logging.Logger;
  5. import jxl.Sheet;
  6. import jxl.Workbook;
  7. import jxl.read.biff.BiffException;
  8.  
  9. /**
  10.  *
  11.  * @author jaka
  12.  */
  13. public class Jxl1 {
  14.  
  15. public static void main(String args[]) {
  16. try {
  17. File excelFile = new File("C:\\sample-file.xls");
  18. Workbook wb = Workbook.getWorkbook(excelFile);
  19. Sheet sheet = wb.getSheet(1);
  20. int column = sheet.getColumns();
  21. int row = sheet.getRows();
  22.  
  23. System.out.println("Total Columns: " + column);
  24. System.out.println("Total Rows: " + row);
  25. } catch (IOException ex) {
  26. Logger.getLogger(Jxl1.class.getName()).log(Level.SEVERE, null, ex);
  27. } catch (BiffException ex) {
  28. Logger.getLogger(Jxl1.class.getName()).log(Level.SEVERE, null, ex);
  29. }
  30. }
  31.  
  32. }

hope will help ..

-jaka
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC