It would appear that the conditional formatting does not even have to be within the PrintArea being converted to image; just has to be defined on the sheet.
The same error seems to occur if you even just touch the Sheet.ConditionalFormattings object on a worksheet; whether or not it has conditional formattings set.
Please use the attached version with new SheetRender API instead of Worksheet.SheetToImage() method. The SheetToImage method would be obsoleted soon.
See the sample code for SheetRender APIs.
Workbook book = new Workbook();
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
int bookPageCount = 0;
Worksheet sheet = book.Worksheets;
SheetRender sr = new SheetRender(sheet, imgOptions);
int sheetPageCount = sr.PageCount;
string subPageName = string.Empty;
for (int j = 0; j < sheetPageCount; j++)
sr.ToImage(j, @“e:\test\Test” + “_” + j.ToString() + “.png”);
bookPageCount += sheetPageCount;
It works fine, but the Gradient fill effects in the C column are not rendered yet, it will be supported soon. I have logged an issue for it with an id: CELLSNET-18330. We will soon look into it and get back to you soon.
Well, yes, I am afraid, some complex conditional formatting types/attributes e.g equal
parameter, data bars, icons set, top bottom etc. are not supported.
Since this is complex feature to be investigated or supported, but we will try to support it before the end of this month or in the first half of the next month.
Thanks for your understanding!