poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yehogold <yehog...@yahoo.com>
Subject Colors in an .xlsx
Date Tue, 18 Aug 2009 19:05:00 GMT

I need to check the color of the fonts in a workbook that I am reading in.  I
was having trouble checking the color of a cell in an .xlsx and so I made
the following test program to check that the font of the first cell in a
workbook was red.  For some reason, although I've set the font red using
excel, the program is telling me that color is '0', while Font.RED is '10'. 
Does anyone know why this is?

<code> public class colorTester
{
	public static void main(String [] args)
	{
		Workbook wb = null;
		try
		{
			FileInputStream inp = new FileInputStream(args[0]);
			wb = WorkbookFactory.create(inp);
			inp.close();
		}
		catch (FileNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (InvalidFormatException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Sheet s = wb.getSheetAt(0);
		Row r = s.getRow(0);
		Cell c = r.getCell(0);
		
	
System.out.println(wb.getFontAt(c.getCellStyle().getFontIndex()).getColor()
+ ":" + 
							Font.COLOR_RED);		
	}
}
</code>

Also, could someone explain how colors in general work in XSSF?  There isn't
any XSSFColor the lists basic colors like HSSFColor.  In the quick guide,
they use org.apache.poi.ss.usermodel.IndexedColors, but the API says that
its deprecated.  

Thank you in advance,

yehogold
-- 
View this message in context: http://www.nabble.com/Colors-in-an-.xlsx-tp25031511p25031511.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message