Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

How to define dynamic cell range for excell sheet using java?

$
0
0
 SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
             ConditionalFormattingRule rule = sheetCF.createConditionalFormattingRule( "MOD(ROW() - 1, 1) = 0");
              PatternFormatting fill = rule.createPatternFormatting();
                style.setFillForegroundColor(IndexedColors.BLUE.index);
                style.setFillPattern(CellStyle.SOLID_FOREGROUND);

                FontFormatting ffRed = rule.createFontFormatting();
                ffRed.setFontColorIndex(IndexedColors.WHITE.index);

                CellRangeAddress[] regions = {  CellRangeAddress.valueOf("A1:ZZ1") };

                sheetCF.addConditionalFormatting(regions,rule);

                ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(
                        "MOD(ROW() - 1, 2) = 0");

                PatternFormatting fill1 = rule1.createPatternFormatting();
                fill1.setFillBackgroundColor(IndexedColors.PALE_BLUE.index);
                fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);

                CellRangeAddress[] regions1 = {  CellRangeAddress.valueOf("A2:ZZ8304") };

                sheetCF.addConditionalFormatting(regions1,rule1);

Hi ,this is my code inside CellRangeAddress.values I gave static value .But i wanted it to be dynamic.That is where ever the data present it should take range dynamically.How to resolve this issue? I reffered stackoverflow.com/questions/33428013/define-dynamic-cell-range but it didn't work.


Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>