You're using the cell style index as an index into the fonts.  Try the
getFontIndex instead.

Regards,

Glen Stampoultzis
[EMAIL PROTECTED]
(03) 9753-6850
0402 835 458


> 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
>   file://HSSFFont         f      = wb.createFont();
>
>   short csIndex = cs.getIndex();
>   System.out.println("Font idx is " + csIndex);
>   file://HSSFFont f = wb.getFontAt(csIndex);
>   file://System.out.println(f.getFontHeightInPoints());
>   System.out.println(c.getStringCellValue());
>   System.out.println(cs.getFillForegroundColor());
>
****************************************************************************
> ****************************************************
>
> Any help appreciated.
>
> thanks
> Swamy


Reply via email to