TOP 10%- BOTTOM 10% conditional formattings don't work

Please run the following code against the attached spreadsheet:

private static void TestBackgroundColorOfConditionallyFormattedCell2()
{
//C:\temp\spreadsheets\test_conditional_formatting_background_color.xlsx
Workbook workbook = new Workbook(@“C:\temp\spreadsheets\test_conditional_formatting_background_color2.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];

workbook.CalculateFormula();

for (int i = 0; i < 9; i++)
{
Cell cell = worksheet.Cells[i, 0];
Style style = cell.GetDisplayStyle();

Color color = GetCellBackgroundColor3(style);
Console.WriteLine(color);

}
// Console.WriteLine((color.ToArgb() & 0xFFFFFF).ToString(“X6”));

Console.WriteLine(GetCellBackgroundColor3(worksheet.Cells[“A13”].GetDisplayStyle()));
}



public static Color GetCellBackgroundColor3(Style displayStyle)
{
// Background color
Color cellBackgroundColor = Color.Empty;

//Read the fill color
if (displayStyle.Pattern == BackgroundType.Solid)
{
cellBackgroundColor = displayStyle.ForegroundColor;
}
return cellBackgroundColor;
}


The background colors in cell A1 and A9 should be different than Empty.

Note, however, the background color reported for A13 is correct.

Thanks


Furthermore, to support your testing, I noticed that duplicate & above average conditional formattings don’t work properly either.

run this program against the attached spreadsheet:

private static void TestBackgroundColorOfConditionallyFormattedCell3()
{
Workbook workbook = new Workbook(@“C:\temp\spreadsheets\test_conditional_formatting_background_color3.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];

workbook.CalculateFormula();

foreach (string cellName in new string[] { “A1”, “A2”, “A3”, “A4”, “A5”, “A6”, “A8”, “A9”, “A16”, “A17” })
{
Cell cell = worksheet.Cells[cellName];
Style style = cell.GetDisplayStyle();

Color color = GetCellBackgroundColor3(style);
Console.WriteLine("{0}: {1}", cellName, color);

}
}


public static Color GetCellBackgroundColor3(Style displayStyle)
{
// Background color
Color cellBackgroundColor = Color.Empty;

//Read the fill color
if (displayStyle.Pattern == BackgroundType.Solid)
{
cellBackgroundColor = displayStyle.ForegroundColor;
}
return cellBackgroundColor;
}

The reported color for A8, A9, A16, A17 is empty. So, certain conditional formattings work, others don’t work.

Can you please test all the possible scenarios?

And, this thread might be related to the other thread I reported: <a href="




Just one more thing, if you want to test more things, I found this spreadsheet on the internet with lots of various conditional formattings.

Please run the following code against the attached spreadsheet:

private static void TestBackgroundColorOfConditionallyFormattedCell2()
{
//C:\temp\spreadsheets\test_conditional_formatting_background_color.xlsx
Workbook workbook = new Workbook(@"C:\temp\spreadsheets\test_conditional_formatting_background_color2.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

workbook.CalculateFormula();

for (int i = 0; i < 9; i++)
{
Cell cell = worksheet.Cells[i, 0];
Style style = cell.GetDisplayStyle();

Color color = GetCellBackgroundColor3(style);
Console.WriteLine(color);

}
// Console.WriteLine((color.ToArgb() & 0xFFFFFF).ToString("X6"));

Console.WriteLine(GetCellBackgroundColor3(worksheet.Cells["A13"].GetDisplayStyle()));
}



public static Color GetCellBackgroundColor3(Style displayStyle)
{
// Background color
Color cellBackgroundColor = Color.Empty;

//Read the fill color
if (displayStyle.Pattern == BackgroundType.Solid)
{
cellBackgroundColor = displayStyle.ForegroundColor;
}
return cellBackgroundColor;
}


The background colors in cell A1 and A9 should be different than Empty.

Note, however, the background color reported for A13 is correct.

Thanks




Hi Costa,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue. The background colors in cell A1 and A9 should be different than Empty and background color reported for A13 is correct. We have logged this issue in our database. We will look into it and fix this issue. Once the issue is fixed or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-42139.

Below is the output of your code for a reference.

Output:
Color [Empty]
Color [Empty]
Color [Empty]
Color [Empty]
Color [Empty]
Color [Empty]
Color [Empty]
Color [Empty]
Color [Empty]
Color [A=0, R=255, G=199, B=206]

Furthermore, to support your testing, I noticed that duplicate & above average conditional formattings don't work properly either.

run this program against the attached spreadsheet:

private static void TestBackgroundColorOfConditionallyFormattedCell3()
{
Workbook workbook = new Workbook(@"C:\temp\spreadsheets\test_conditional_formatting_background_color3.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

workbook.CalculateFormula();

foreach (string cellName in new string[] { "A1", "A2", "A3", "A4", "A5", "A6", "A8", "A9", "A16", "A17" })
{
Cell cell = worksheet.Cells[cellName];
Style style = cell.GetDisplayStyle();

Color color = GetCellBackgroundColor3(style);
Console.WriteLine("{0}: {1}", cellName, color);

}
}


public static Color GetCellBackgroundColor3(Style displayStyle)
{
// Background color
Color cellBackgroundColor = Color.Empty;

//Read the fill color
if (displayStyle.Pattern == BackgroundType.Solid)
{
cellBackgroundColor = displayStyle.ForegroundColor;
}
return cellBackgroundColor;
}

The reported color for A8, A9, A16, A17 is empty. So, certain conditional formattings work, others don't work.

Can you please test all the possible scenarios?

And, this thread might be related to the other thread I reported: CELLSNET-42140.

Below is the output of your code for a reference.

Output:
A1: Color [A=0, R=255, G=199, B=206]
A2: Color [A=0, R=255, G=199, B=206]
A3: Color [A=0, R=255, G=235, B=156]
A4: Color [A=255, R=147, G=205, B=221]
A5: Color [A=0, R=255, G=199, B=206]
A6: Color [A=0, R=255, G=199, B=206]
A8: Color [Empty]
A9: Color [Empty]
A16: Color [Empty]
A17: Color [Empty]

Hi,

Please download and try our latest version/fix: Aspose.Cells for .NET v7.7.0.2 and let us know your feedback.


We have fixed the issues ( “CELLSNET-42139” and “CELLSNET-42140”).

Thank you.

The issues you have found earlier (filed as CELLSNET-42139) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.