943,697 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3234
  • Java RSS
May 26th, 2009
0

Read Excel Sheet

Expand 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
Last edited by sneharaveendran; May 26th, 2009 at 7:09 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sneharaveendran is offline Offline
3 posts
since Apr 2009
May 26th, 2009
0

Re: Read Excel Sheet

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/
Reputation Points: 485
Solved Threads: 89
Posting Shark
verruckt24 is offline Offline
944 posts
since Nov 2008
May 26th, 2009
-1

Re: Read Excel Sheet

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.
Java Syntax (Toggle Plain Text)
  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
Reputation Points: 9
Solved Threads: 3
Newbie Poster
jaka.ramdani is offline Offline
18 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Efficient Perfect Number
Next Thread in Java Forum Timeline: Format SQL Server Dates





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC