poi hssf getCellStyle problem

C

cosmo

hey there,

i have a big problem with those cellstyles. i want to add background
color to some cells, but apparently i just can "change" cell styles
from cells which already "have one".
for better understanding of my problem, here's the code:

for ( int i = 0; i <= rowcount; i++ ) {
for (int j = 0; j <= colcount; j++) {
HSSFRow row = s1.getRow((short)i);
if (row != null) {
HSSFCell cell = row.getCell((short)j);
if (cell != null) {
HSSFCellStyle style = cell.getCellStyle();
style.setFont(font);
style.setWrapText(true);
style.setFillForegroundColor(colorIndex);

if ( (j%4== 0) && (colorIndex ==
HSSFColor.LIGHT_CORNFLOWER_BLUE.index) ) {
colorIndex = HSSFColor.LEMON_CHIFFON.index;
}
else if ( (j%4== 0) && (colorIndex ==
HSSFColor.LEMON_CHIFFON.index) ) {
colorIndex =
HSSFColor.LIGHT_CORNFLOWER_BLUE.index;
}
}
}
}
}
}

this piece of code just works for cells, which already have attributes
in their cell styles like background color and border. cells which
just have a border and no color won't get the instructed color...

does anybody know what to do? is the method cell.getCellStyle() not
the best option in this case?

best regards and thx in advance,
manuela
 
Joined
Jan 18, 2008
Messages
1
Reaction score
0
can u help me??

i need to transfer data from a xls sheet to xls sheet..thats done..but i am not able to tansfer it with same font size...the destination sheet takes data in default 'arial 10' font..where as source sheet has 'arail 8'...plz help:-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

POI HSSF Cell Style question 0
problem with poi and row height 0
Apache HSSF Problem 0
Image on header 2
Jakarta POI 0
Java and apach poi = read Excel cell 3
HSSF workbook 0
Apache POI, ExcelSheet & Jar... 9

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top