excel - XLS - Conditional Formatting - Java POI Example -
:) after research found solution problem, not yet satisfied
i use conditional formatting show line yellow color if column b , c same line not have same value. marco on vba i'm not using me undrstund
= 3 fin step 1 range("c" & i).select selection.formatconditions.delete selection.formatconditions.add type:=xlcellvalue, operator:=xlnotequal, _ formula1:="=b" & selection.formatconditions(1).interior.colorindex = 6
this 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 shows me yellow colored line. you've seen have values that = 120 displayed color yellow. problem think values are not in digital format in page .. not problem
my real problem value have comprare with, not know how have expressed each box b , c of same line. put here single value = 120 test
how should .. @ value comprarer thank in advance :)
finaly solution works fine ..think @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 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();
Comments
Post a Comment