Skip to content

Instantly share code, notes, and snippets.

@seancoyne
Last active January 3, 2016 10:09
Show Gist options
  • Save seancoyne/8447155 to your computer and use it in GitHub Desktop.
Save seancoyne/8447155 to your computer and use it in GitHub Desktop.
Get XLS cell bg color
<cfscript>
xls = "/path/to/file.xls";
ss = spreadsheetread(xls);
cell = ss.getWorkbook().getSheetAt(0).getRow(0).getCell(0);
style = cell.getCellStyle();
colorCode = style.getFillForegroundColor();
greenCode = createobject('java', 'org.apache.poi.hssf.util.HSSFColor$GREEN').getIndex();
greyCode = createobject('java', 'org.apache.poi.hssf.util.HSSFColor$GREY_80_PERCENT').getIndex();
yellowCode = createobject('java', 'org.apache.poi.hssf.util.HSSFColor$YELLOW').getIndex();
if (colorCode == greenCode) {
// do green
} else if (colorCode == greyCode) {
// do grey
} else if (colorCode == yellowCode) {
// do yellow
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment