导出Excel,根据状态(open/closed)设置背景色,open,背景色为白色,closed灰色导出结果第二行closed本为灰色却变成了白色,第六行状态open背景色应为白色却成了灰色,
代码: private void rowsPrint(ExcelXmlParser parser, HttpServletResponse resp) throws WriteException, IOException {
ExcelRow[] rows = parser.getGridContent();
for (int i = 0; i <rows.length; i++) {
String[] cells = rows[i].getCells();
//标记当前行是否为Closed
boolean isClosed=false;
sheet.setRowView(i + headerOffset, 400);
Cell cell=sheet.getCell(11, i);//业务状态
if(cell.getContents().equals("Closed")){
isClosed=true;
}
for (int j = 0; j < cells.length; j++) {
WritableFont font = new WritableFont(WritableFont.TAHOMA, 10);
WritableCellFormat f = new WritableCellFormat (font);
if(isClosed){
f.setBackground(Colour.GRAY_25);//#E3EFFF
}else{
f.setBackground(Colour.WHITE);
}
代码: private void rowsPrint(ExcelXmlParser parser, HttpServletResponse resp) throws WriteException, IOException {
ExcelRow[] rows = parser.getGridContent();
for (int i = 0; i <rows.length; i++) {
String[] cells = rows[i].getCells();
//标记当前行是否为Closed
boolean isClosed=false;
sheet.setRowView(i + headerOffset, 400);
Cell cell=sheet.getCell(11, i);//业务状态
if(cell.getContents().equals("Closed")){
isClosed=true;
}
for (int j = 0; j < cells.length; j++) {
WritableFont font = new WritableFont(WritableFont.TAHOMA, 10);
WritableCellFormat f = new WritableCellFormat (font);
if(isClosed){
f.setBackground(Colour.GRAY_25);//#E3EFFF
}else{
f.setBackground(Colour.WHITE);
}
解决方案 »
- 找ibatis配置文件的根路径
- Spring错误:Pointcut is malformed: error at ::0 formal unbound in
- 求一个正规表达式,删除字符串中的数字和符号,用空隔代替,但是如果是汉字的电码\0000-\9999不能删除
- Hibernate PO类的编写
- 请教commonupload图片上传的路径问题
- 在Struts框架中,如何解决内存溢出的问题?
- webservice的问题
- 大家来说说程序员的研究方向吧!
- 开发介绍公司情况基于触摸屏的软件,怎么实现接口
- tomcat配置访问文件的三种方式
- spring+hibernate问题!
- 奇怪的环境变量问题(急急急,在线等待)
Cell cell=sheet.getCell(11, i+1)//业务状态
for (int j = 0; j < cells.length; j++) {
WritableFont font = new WritableFont(WritableFont.TAHOMA, 10);
WritableCellFormat f = new WritableCellFormat (font);
if(isClosed){
f.setBackground(Colour.GRAY_25);//#E3EFFF
}else{
f.setBackground(Colour.WHITE);
}
你这个背景颜色设置到哪个CELL上了???
if(cell.getContents().equals("Closed")){
isClosed=true;
}
调试下,看下取出来得第一行的状态是Closed么?是不是取出的数据有问题。
if(cell.getContents().equals("Closed")){
isClosed=true;
}
调试下,看下取出来得第一行的状态是Closed么?是不是取出的数据有问题。