Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java生成的excel排序颜色混乱_Java_Jxl - Fatal编程技术网

java生成的excel排序颜色混乱

java生成的excel排序颜色混乱,java,jxl,Java,Jxl,我正在使用jxl api生成excel工作表,在该工作表中,备用行高亮显示,当我对excel内容进行排序并手动排序时,单元格背景颜色混乱,通常这是因为我正在逐个单元格编写颜色单元格,在生成excel时,是否有任何方法可以为备用行着色,这样做不会影响内容的排序。您是否尝试过使用行视图: Sheet s = ... Colour[] colorings = new Colour[]{Colour.GOLD, Colour.OCEAN_BLUE}; for(int i=0;i<s.getRows

我正在使用jxl api生成excel工作表,在该工作表中,备用行高亮显示,当我对excel内容进行排序并手动排序时,单元格背景颜色混乱,通常这是因为我正在逐个单元格编写颜色单元格,在生成excel时,是否有任何方法可以为备用行着色,这样做不会影响内容的排序。

您是否尝试过使用行视图:

Sheet s = ...
Colour[] colorings = new Colour[]{Colour.GOLD, Colour.OCEAN_BLUE};
for(int i=0;i<s.getRows();i++){
  CellView rowView = s.getRowView(i);
  WritableCellFormat newFormat = new WritableCellFormat(rowView.getFormat());
  newFormat.setBackground(colorings[i%2]);
  rowView.setFormat(newFormat());
}
工作表s=。。。
颜色[]颜色=新颜色[]金,颜色.海洋蓝};

对于(int i=0;我希望回答Jessup,我猜发布的问题给出了不同的含义,我的问题的解决方案可以通过在excel中使用条件格式手动解决,jxl生成的excel Sheet具有唯一格式的标题行,其余行也会高亮显示,当我对con排序时会出现问题通过在excel中选择行->数据菜单->排序,可以在手动解决方案中使用“=mod(row(),2)=1”等条件格式对数据进行排序,并使用背景颜色进行排序,在这种情况下,仅对内容进行排序,知道吗?我的要求是不应对背景颜色进行排序,而应仅对内容进行排序..希望我没有混淆您..了解,据我所知,当前版本的库不支持条件格式。