poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "cool.aquarian" <glasska...@gmail.com>
Subject Copy Conditional formatting from one Worksheet to another
Date Wed, 05 Jul 2017 20:47:43 GMT
Hello,

I am trying to copy conditional formatting in one .xlsx worksheet to another
(in a generic way). Here is what I am doing:
<code>
			XSSFSheet xssfSheet = (XSSFSheet) sheet;                //source sheet
			XSSFSheet newXssfSheet = (XSSFSheet) newSheet;   //target sheet
			XSSFSheetConditionalFormatting scf =
xssfSheet.getSheetConditionalFormatting();
			XSSFSheetConditionalFormatting nscf =
newXssfSheet.getSheetConditionalFormatting();

			for (int idx = 0; idx < scf.getNumConditionalFormattings(); idx++) {
				XSSFConditionalFormatting cf = scf.getConditionalFormattingAt(idx);
				nscf.addConditionalFormatting(cf);
			}
</code>

I can see that this gets the conditional formatting sections from original
sheet correctly.
But when I write the new sheet to a file, it makes the excel to ask to
repair the worksheet after opening.

Any advise on this?



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Copy-Conditional-formatting-from-one-Worksheet-to-another-tp5728044.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message