:) Finally after the research I found the solution to my problem, which is not yet satisfied
:)最后在研究后我找到了我的问题的解决方案,但尚未满足
I would like to use conditional formatting to show a line with a yellow color if column B and C to the same line does not have the same value. this is the marco on VBA I'm not using it just for help me undrstund
如果同一行的B列和C列不具有相同的值,我想使用条件格式来显示黄色的行。这是VBA上的marco我不是用它来帮我解决
For i = 3 To fin Step 1
Range("C" & i).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=B" & i
Selection.FormatConditions(1).Interior.ColorIndex = 6
this is My Methode java .it is like this But
这是我的Methode java .it就是这样但是
FileInputStream file = new FileInputStream(new File("D://DEQ//"+selectitem.getRefDeq()+"//Comparatif.xls"));
HSSFWorkbook workbook1 = new HSSFWorkbook(file);
HSSFSheet sheet1 = workbook1.getSheet("page1");
HSSFSheetConditionalFormatting cf =sheet1.getSheetConditionalFormatting();
HSSFConditionalFormattingRule cfrole=cf.createConditionalFormattingRule(org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator.NOT_EQUAL, "120");
HSSFPatternFormatting fill_pattern = cfrole.createPatternFormatting();
fill_pattern.setFillBackgroundColor(IndexedColors.YELLOW.index);
CellRangeAddress[] my_data_range = {CellRangeAddress.valueOf("B17:B26")};
cf.addConditionalFormatting(my_data_range,cfrole);
FileOutputStream out = new FileOutputStream(new File("D://DEQ//"+selectitem.getRefDeq()+"//Comparatif.xls"));
workbook1.write(out);
out.close();
this example work well it shows me the yellow colored line. but as you've already seen I have values that are a = 120 which is displayed with the color yellow. problem is that I think the values are not in the digital format in my page .. this is not a problem
这个例子效果很好,它向我展示了黄色的线条。但正如您已经看到的那样,我的值为a = 120,并以黄色显示。问题是我认为我的页面中的值不是数字格式..这不是问题
My real problem is the value that I have to comprare with, I do not know how I have expressed that each box B and C of the same line. I put here a single value = 120 only for test
我真正的问题是我必须要比较的价值,我不知道我是如何表达同一行的每个方框B和C.我把这里的单个值= 120只用于测试
How should I do .. at the value comprarer thank you in advance :)
我应该怎么做..在价值评估者,提前谢谢你:)
2 个解决方案
#1
3
Finaly this is my solution it works fine ..think you @Philip
最后这是我的解决方案,它工作得很好..想你@Philip
FileInputStream file = new FileInputStream(new File("D://DEQ//"+selectitem.getRefDeq()+"//Comparatif.xls"));
HSSFWorkbook workbook1 = new HSSFWorkbook(file);
HSSFSheet sheet1 = workbook1.getSheet("Comparatif");
//Get first sheet from the workbook
HSSFSheetConditionalFormatting cf =sheet1.getSheetConditionalFormatting();
int i;
i=17;
for(;i<=ligne;i++){
HSSFConditionalFormattingRule cfrole=cf.createConditionalFormattingRule(ComparisonOperator.NOT_EQUAL,"$C$"+i );
HSSFPatternFormatting fill_pattern = cfrole.createPatternFormatting();
fill_pattern.setFillBackgroundColor(IndexedColors.YELLOW.index);
CellRangeAddress[] my_data_range = {CellRangeAddress.valueOf("B"+i+":B"+i)};
cf.addConditionalFormatting(my_data_range,cfrole);
}
for(i=17;i<=ligne;i++){
HSSFConditionalFormattingRule cfrole=cf.createConditionalFormattingRule(ComparisonOperator.NOT_EQUAL,"$B$"+i );
HSSFPatternFormatting fill_pattern = cfrole.createPatternFormatting();
fill_pattern.setFillBackgroundColor(IndexedColors.YELLOW.index);
CellRangeAddress[] my_data_range = {CellRangeAddress.valueOf("C"+i+":C"+i)};
cf.addConditionalFormatting(my_data_range,cfrole);
}
FileOutputStream out = new FileOutputStream(new File("D://DEQ//"+selectitem.getRefDeq()+"//Comparatif.xls"));
workbook1.write(out);
out.close();
#2
1
you can get the value property of the Cell object, and if the contents are numeric, the value will be numeric.
您可以获取Cell对象的value属性,如果内容是数字,则该值将为数字。
#1
3
Finaly this is my solution it works fine ..think you @Philip
最后这是我的解决方案,它工作得很好..想你@Philip
FileInputStream file = new FileInputStream(new File("D://DEQ//"+selectitem.getRefDeq()+"//Comparatif.xls"));
HSSFWorkbook workbook1 = new HSSFWorkbook(file);
HSSFSheet sheet1 = workbook1.getSheet("Comparatif");
//Get first sheet from the workbook
HSSFSheetConditionalFormatting cf =sheet1.getSheetConditionalFormatting();
int i;
i=17;
for(;i<=ligne;i++){
HSSFConditionalFormattingRule cfrole=cf.createConditionalFormattingRule(ComparisonOperator.NOT_EQUAL,"$C$"+i );
HSSFPatternFormatting fill_pattern = cfrole.createPatternFormatting();
fill_pattern.setFillBackgroundColor(IndexedColors.YELLOW.index);
CellRangeAddress[] my_data_range = {CellRangeAddress.valueOf("B"+i+":B"+i)};
cf.addConditionalFormatting(my_data_range,cfrole);
}
for(i=17;i<=ligne;i++){
HSSFConditionalFormattingRule cfrole=cf.createConditionalFormattingRule(ComparisonOperator.NOT_EQUAL,"$B$"+i );
HSSFPatternFormatting fill_pattern = cfrole.createPatternFormatting();
fill_pattern.setFillBackgroundColor(IndexedColors.YELLOW.index);
CellRangeAddress[] my_data_range = {CellRangeAddress.valueOf("C"+i+":C"+i)};
cf.addConditionalFormatting(my_data_range,cfrole);
}
FileOutputStream out = new FileOutputStream(new File("D://DEQ//"+selectitem.getRefDeq()+"//Comparatif.xls"));
workbook1.write(out);
out.close();
#2
1
you can get the value property of the Cell object, and if the contents are numeric, the value will be numeric.
您可以获取Cell对象的value属性,如果内容是数字,则该值将为数字。