Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When I tried to write data, i also wrote code to set Cell Style using Cell Style class. after execution of the code. it creates excel file with just data not cell Styles. Can anyone please tell me why? I also search everywhere. My Code is same as what every where suggested.

CellStyle styleGreen = cell.getRow().getSheet().getWorkbook().createCellStyle();
styleGreen.setBorderBottom(CellStyle.BORDER_MEDIUM_DASHED);
cell.setCellStyle(sty??leGreen); 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
413 views
Welcome To Ask or Share your Answers For Others

1 Answer

Re-using your code I simply wrote :

CellStyle styleGreen = cell.getRow().getSheet().getWorkbook().createCellStyle();

styleGreen.setBorderBottom(CellStyle.BORDER_MEDIUM_DASHED);

cell.setCellValue("value"); // testing with some value in the cell
cell.setCellStyle(styleGreen);

And it worked , that's why I suppose the error come from your following code , make sure you do not re-use this style in your code below otherwise you'll end up modifying the previous cells, instead just create a new one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...