Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

:) 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

    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

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

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

How should I do .. at the value comprarer thank you in advance :)

share|improve this question
add comment

2 Answers

Finaly this is my solution it works fine ..think you @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();
share|improve this answer
add comment

you can get the value property of the Cell object, and if the contents are numeric, the value will be numeric.

share|improve this answer
    
think you @philip .I'm getting a result now ,but a couldn't post my anser because I don't have the 10 repution hhhhh:) –  salvador May 10 '13 at 7:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.