Setting background custom color, XSSFWorkbook
up vote
0
down vote
favorite
I use this code to change the font in excel to color, which I define
Color sColor = new Color (value,0,0);
XSSFColor userColor = new XSSFColor(sColor);
CellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
font.setColor(userColor);
style.setFont(font);
cell.setCellStyle(style);
Can I change the cell's Background same way.
I saw the question here
Setting background custom color not working for XSSF in Apache POI
And I used the code:
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cell.setCellStyle(cellStyle);
The background still always white.
Am sure that all other parts of the code written properly, because it works when I changed the font.
I have office 2010 on my computer
java excel apache
add a comment |
up vote
0
down vote
favorite
I use this code to change the font in excel to color, which I define
Color sColor = new Color (value,0,0);
XSSFColor userColor = new XSSFColor(sColor);
CellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
font.setColor(userColor);
style.setFont(font);
cell.setCellStyle(style);
Can I change the cell's Background same way.
I saw the question here
Setting background custom color not working for XSSF in Apache POI
And I used the code:
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cell.setCellStyle(cellStyle);
The background still always white.
Am sure that all other parts of the code written properly, because it works when I changed the font.
I have office 2010 on my computer
java excel apache
"but I had error on" what error? compiler error? runtime error? what is the error/what is it supposed to be doing that its not?
– scigs
Nov 7 at 20:50
@scigs can you please see the question after editing.
– Ezz Eddin Othman
Nov 10 at 17:44
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use this code to change the font in excel to color, which I define
Color sColor = new Color (value,0,0);
XSSFColor userColor = new XSSFColor(sColor);
CellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
font.setColor(userColor);
style.setFont(font);
cell.setCellStyle(style);
Can I change the cell's Background same way.
I saw the question here
Setting background custom color not working for XSSF in Apache POI
And I used the code:
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cell.setCellStyle(cellStyle);
The background still always white.
Am sure that all other parts of the code written properly, because it works when I changed the font.
I have office 2010 on my computer
java excel apache
I use this code to change the font in excel to color, which I define
Color sColor = new Color (value,0,0);
XSSFColor userColor = new XSSFColor(sColor);
CellStyle style = wb.createCellStyle();
XSSFFont font = wb.createFont();
font.setColor(userColor);
style.setFont(font);
cell.setCellStyle(style);
Can I change the cell's Background same way.
I saw the question here
Setting background custom color not working for XSSF in Apache POI
And I used the code:
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cell.setCellStyle(cellStyle);
The background still always white.
Am sure that all other parts of the code written properly, because it works when I changed the font.
I have office 2010 on my computer
java excel apache
java excel apache
edited Nov 10 at 17:43
asked Nov 7 at 20:47
Ezz Eddin Othman
488
488
"but I had error on" what error? compiler error? runtime error? what is the error/what is it supposed to be doing that its not?
– scigs
Nov 7 at 20:50
@scigs can you please see the question after editing.
– Ezz Eddin Othman
Nov 10 at 17:44
add a comment |
"but I had error on" what error? compiler error? runtime error? what is the error/what is it supposed to be doing that its not?
– scigs
Nov 7 at 20:50
@scigs can you please see the question after editing.
– Ezz Eddin Othman
Nov 10 at 17:44
"but I had error on" what error? compiler error? runtime error? what is the error/what is it supposed to be doing that its not?
– scigs
Nov 7 at 20:50
"but I had error on" what error? compiler error? runtime error? what is the error/what is it supposed to be doing that its not?
– scigs
Nov 7 at 20:50
@scigs can you please see the question after editing.
– Ezz Eddin Othman
Nov 10 at 17:44
@scigs can you please see the question after editing.
– Ezz Eddin Othman
Nov 10 at 17:44
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Create cell style object:
CellStyle backgroundStyle = workbook.createCellStyle();
Set custom color:
backgroundStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
Add style to the cell:
cell.setCellStyle(backgroundStyle);
add a comment |
up vote
0
down vote
accepted
Thanks all
I found solution now
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setFillForegroundColor(color);
cell.setCellStyle(cellStyle);
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Create cell style object:
CellStyle backgroundStyle = workbook.createCellStyle();
Set custom color:
backgroundStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
Add style to the cell:
cell.setCellStyle(backgroundStyle);
add a comment |
up vote
0
down vote
Create cell style object:
CellStyle backgroundStyle = workbook.createCellStyle();
Set custom color:
backgroundStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
Add style to the cell:
cell.setCellStyle(backgroundStyle);
add a comment |
up vote
0
down vote
up vote
0
down vote
Create cell style object:
CellStyle backgroundStyle = workbook.createCellStyle();
Set custom color:
backgroundStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
Add style to the cell:
cell.setCellStyle(backgroundStyle);
Create cell style object:
CellStyle backgroundStyle = workbook.createCellStyle();
Set custom color:
backgroundStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
Add style to the cell:
cell.setCellStyle(backgroundStyle);
answered Nov 7 at 21:00
Centos
17519
17519
add a comment |
add a comment |
up vote
0
down vote
accepted
Thanks all
I found solution now
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setFillForegroundColor(color);
cell.setCellStyle(cellStyle);
add a comment |
up vote
0
down vote
accepted
Thanks all
I found solution now
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setFillForegroundColor(color);
cell.setCellStyle(cellStyle);
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Thanks all
I found solution now
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setFillForegroundColor(color);
cell.setCellStyle(cellStyle);
Thanks all
I found solution now
XSSFCellStyle cellStyle = wb.createCellStyle();
XSSFColor color = new XSSFColor(new java.awt.Color(value, 0, 0));
((XSSFCellStyle)cellStyle).setFillBackgroundColor(color);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setFillForegroundColor(color);
cell.setCellStyle(cellStyle);
answered Nov 10 at 18:15
Ezz Eddin Othman
488
488
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53197569%2fsetting-background-custom-color-xssfworkbook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"but I had error on" what error? compiler error? runtime error? what is the error/what is it supposed to be doing that its not?
– scigs
Nov 7 at 20:50
@scigs can you please see the question after editing.
– Ezz Eddin Othman
Nov 10 at 17:44