SheetToImage Fails when Conditional Formatting is specified

Hi There;


There seems to be a problem with SheetToImage when conditional formatting is specified on a worksheet - an exception is thrown.

I have attached a sample workbook illustrating the problem. Stripping my code right back to the following still produces the error.

Workbook wb = new Workbook();
wb.Open(“TEST.xlsx”);
Image i = wb.Worksheets[0].SheetToImage();

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.

Regards,
Simon

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.


I thought perhaps I could work around the issue by clearing the conditional formatting, however, if I call
Sheet.ConditionalFormattings.Clear()
the SheetToImage fails, whether there were conditional formatting defined on the sheet or not.

Hi,

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();
book.Open(@“e:\test\TEST.xlsx”);

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
int bookPageCount = 0;

Worksheet sheet = book.Worksheets[0];
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.

Thank you.


Hi There;


Thanks for the feedback. Using the SheetRender with the correct options does indeed output without error when there are conditional formats in the worksheet.

I look forward to the color range conditional formatting working as well. Thanks again for the quick response.

Regards,
Simon

Hi There


After some more testing, while there is no longer an exception raised using this other method, it would appear that a significant number of the conditional formating options are not supported in the renderer as yet (although it would appear that it’s not just the renderer, using cell.GetConditionalStyle also doesn’t return the correct style for these).

I’ve attached my sample workbook that I was using fer testing, it appears that only greater than / less than / between are fully implemented at this stage (equal appears to be having an issue with times).

I understand that this is probably more of a ‘not supported at this stage’ thing rather than a bug, however is there a timeframe for supporting the rest of these formats, or is it something that is a long way off (or not at all (ie I can see possible issues with databars / icon sets))? Basically just looking for some more info so I can know when / if to expect support for these formats.

Thanks for the help;
Regards,

Simon


Hi Simon,

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!