Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using JXL (JExcelAPI)

807569Jul 28 2006 — edited Jul 28 2006
Hi,
(Firstly sorry because also I have post this in forum "Core APIs Generics", but I have not answer)

Finally I am using the API jxl to read xls files.
I be able to open and obtain the content of any cell, but my problem is other.
I need to open a xls file (I will not know how many columns and rows it has) and I need to know how many columns and rows it has.

My code to obtain the content of any cell is:
import jxl.Workbook;
import jxl.Sheet;
import jxl.Cell;
import jxl.*;
 
public class create{	
	private static File excelFile;
	private int numCols;
	private int numRows;
	public static void main(String[] args) throws Exception {
		Workbook book= Workbook.getWorkbook(new File("test.xls"));
		Sheet mySheet= libro.getSheet(0);
		
		Cell a1 = mySheet.getCell(0,0);
		Cell b2 = mySheet.getCell(1,1);
 
		System.out.println("Cell A1: " + a1.getContents());
		System.out.println("Cell B2: " + b2.getContents());
		//now I need to know how many cols and rows it has
		read();
		System.out.println("OK");
		
		book.close();
	}
	final static void read(){
		excelFile = new File("test.xls","r");
		boolean cont = true;
		
		System.out.println("OK READ");
	}
}
How can I do?
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2006
Added on Jul 28 2006
1 comment
267 views