-----Original Message-----
From: Thutika, Swamy
Sent: Wednesday, January 30, 2002 10:11 AM
To: '[EMAIL PROTECTED]'
Subject: How to get the FONT object of a cell?
Hi all,
I am trying to read an xls file and get the font of a cell. How do I do
that?? I use 120 version
When I tried to get font index for that i get following error:
Font idx is 22
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
There only 6 font records, you asked for 22
Here is the code snippet:
****************************************************************************
*********************************************
POIFSFileSystem fs = new POIFSFileSystem(new
FileInputStream("myfile.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs); // create a workbook
reference
HSSFSheet s = wb.getSheetAt(0); // create a new sheet
HSSFRow r = s.getRow(0); // get the first row object
reference
HSSFCell c = r.getCell((short)1); // get the first cell
object reference
HSSFCellStyle cs = c.getCellStyle(); // get the cell style
//HSSFFont f = wb.createFont();
short csIndex = cs.getIndex();
System.out.println("Font idx is " + csIndex);
//HSSFFont f = wb.getFontAt(csIndex);
//System.out.println(f.getFontHeightInPoints());
System.out.println(c.getStringCellValue());
System.out.println(cs.getFillForegroundColor());
****************************************************************************
****************************************************
Any help appreciated.
thanks
Swamy