Conditional formatting. Compatibility problems with *.xls

Hi,


I created a simple *.xlsx document and converted it to *.xls by Excel 2010.
Here is base block of code, that used in all samples:
gXl = new Workbook(fName);
foreach (Worksheet ws in gXl.Worksheets)
{
foreach (FormatConditionCollection fcc in ws.ConditionalFormattings)
{
for (int i = 0; i < fcc.Count; i++)
{
FormatCondition fc = fcc[i];
// Checking type of current object to print valid fields
// Here we call code from samples
}
}
}
1. Type - ColorScale (Excel: Format all cells based on their values - 2 - Color Scale).
Type - Number
Value:
*.xlsx - ‘=0’
*.xls - ‘0’
Such type of value has the same incompatibilities in the other rules.
Cell in the attached document (Sheet1): A2
Code:
ConditionalFormattingValue cfv;
cfv = fc.ColorScale.MinCfvo;
printLine(“Value”, cfv.Value.ToString(), SPACE4); // my inner printing method
2. Type - ColorScale (Excel: Format all cells based on their values - 2 - Color Scale).
Type - Number
Value:
*.xlsx - ‘=$A$2’
*.xls - ‘=Sheet1!$A$2’
Such type of value has the same incompatibilities in the other rules.
Cell in the attached document (Sheet1): A4
Code:
ConditionalFormattingValue cfv;
cfv = fc.ColorScale.MinCfvo;
printLine(“Value”, cfv.Value.ToString(), SPACE4); // my inner printing method
3. Type - IconSet (Excel: Format all cells based on their values).
Type:
*.xlsx - TrafficLights32
*.xls - Signs3
Range of cells (Sheet1): [G5:K5]
A vice versa problem in range (Sheet1): [G6:K6]
Code:
printLine(“Type”, Enum.GetName(typeof(IconSetType), fc.IconSet.Type), SPACE3); // my inner printing method
4. Type - CellValue (Excel: Format only cells that contain - Cell Value).
Operator:
*.xlsx - GreaterOrEqual
*.xls - GreaterThan
Cell in the attached document (Sheet2): A7
Code:
printLine(“Operator”, Enum.GetName(typeof(OperatorType), fc.Operator), SPACE3); // my inner printing method
5. Type - TimePeriod (Excel: Format only cells that contain - Dates Occurring).
TimePeriod:
*.xlsx - NextMonth
*.xls - ThisMonth
Cell in the attached document (Sheet2): E10
Code:
printLine(“TimePeriod”, Enum.GetName(typeof(TimePeriodType), fc.TimePeriod), SPACE3); // my inner printing method
6. Type - DuplicateValues (Excel: Format only unique or duplicate values).
Type:
*.xlsx - DuplicateValues
*.xls - Expression
Cell in the attached document (Sheet3): E1
Code:
printLine(“Type”, Enum.GetName(typeof(FormatConditionType), fc.Type), SPACE2); // my inner printing method
I use Aspose.Cells v7.1.2.0.

Thank you,
Alex Shloma

Hi,


Thanks for the sample files and code segments.

I did notice some differences as you pointed out. We will look into it why it gives different values for XLSX and XLS files although as you pointed out you just re-saved the XLSX file as XLS file.

I have logged a ticket with an id: CELLSNET-40526. Once we have any update, we will let you know here.

Thank you

Hi,


I found more few similar problems.
7. Type - UniqueValues (Excel: Format only unique or duplicate values).
Style - Font - Color:
*.xlsx - Color [Black]
*.xls - Color [A=0, R=0, G=0, B=0]
Style - Font - IsStrikeout:
*.xlsx - True
*.xls - False
Cell in the attached document (Sheet1): A1
Code:
Style style = fc.Style;
printLine(“Color”, style.Font.Color.ToString(), SPACE5); // my inner printing method
printLine(“IsStrikeout”, style.Font.IsStrikeout.ToString(), SPACE5);
8. Type - UniqueValues (Excel: Format only unique or duplicate values).
Style:
*.xlsx
BackgroundColor - Color [A=0, R=0, G=112, B=192]
Pattern - None
ForegroundColor - Color [A=0, R=255, G=255, B=0]
GetTwoColorGradient:
Color1 - Color [A=0, R=255, G=255, B=0]
Color2 - Color [A=0, R=0, G=112, B=192]
Variant - 4
*.xls
BackgroundColor - Color [A=0, R=192, G=112, B=0]
Pattern - Solid
ForegroundColor - Color [A=0, R=0, G=255, B=255]
GetTwoColorGradient:
Color1 - Color [A=0, R=0, G=255, B=255]
Color2 - Color [A=0, R=192, G=112, B=0]
Variant - 2
Cell in the attached document (Sheet1): A2
Code:
Style style = fc.Style;
printLine(“BackgroundColor”, style.BackgroundColor.ToString(), SPACE4); // my inner printing method
printLine(“Pattern”, Enum.GetName(typeof(BackgroundType), style.Pattern), SPACE4);
printLine(“ForegroundColor”, style.ForegroundColor.ToString(), SPACE4);
if (style.IsGradient)
{
Color color1, color2;
GradientStyleType gst;
int variant;
style.GetTwoColorGradient(out color1, out color2, out gst, out variant);

printLine(“Color1”, color1.ToString(), SPACE5);
printLine(“Color2”, color2.ToString(), SPACE5);
printLine(“Variant”, variant.ToString(), SPACE5);
}

Thanks,
Alex Shloma

Hi,



Thanks for your posting describing few similar problems.



We have logged it against the issue id: CELLSNET-40526



We will get back to you asap.

Hi,

We fixed this issue. Please download and try the latest version: Aspose.Cells for .NET v7.1.2.7

Thank you!


I’ve checked out last version and noticed that not all is fixed:
2. Nothing changed.
7. First discrepancy.
Style - Font - Color:
*.xlsx - Color [Black]
*.xls - Color [A=0, R=0, G=0, B=0]

Thanks,
Alex Shloma

Hi,

You mentioned so many issues in a single thread. Please create a separate thread for your separate issues.

It will be helpful in sorting out the issues quickly and keep track of them.

Hi,

For your other two issues:

#2. Formula issue of “=Sheet1!$A$2” and "=$A$2"
Those formulas are both read from corresponding template file. In fact it is strange to us that the formula in your given xls is “=Sheet1!$A$2”. We don’t know how did you create this XLS file, at our end when we save the XLSX as XLS by excel2007, in the saved XLS file the formula was “=$A$2”(same with the formula in XLSX file), not “=Sheet1!$A$2”. Anyways, because ms excel does not allow reference to other worksheet than the sheet where the format condition is in, so “=$A$2” is always equals to “=Sheet1!$A$2” for the conditional formattings in Sheet1.

#7. Color[Black] and [ARGB=0]
In the given xlsx template file, the font color is using theme color and the color is the pre-defined one(Black). When reading XLS file, currently we cannot get the theme color and only read the color in RGB. However, user should compare colors by their ARGB values in all situations. For Black and Color[ARGB=0], they are same.

Hi,


7. I agree, that those are the same colors. I reported about them, because this is a strange behaviour. There are other colors with the same value, but some converting to ‘[A=0, R=0, G=0, B=0]’ representation of black, and another stay with the same ‘[Black]’. When I do a reverse conversion (*.xls -> *.xlsx), I get the my ‘[Black]’ values back.

Thank you,
Alex Shloma

Hi,

Thanks for your input.

I have logged your comments in our database. Development team will look into your issues and give you advice on these issues.

  1. 374848

  2. 374861

The comments have been logged against the issue id: CELLSNET-40526

Hi,

For the color [Black] and [ARGB=0], as we have said, it is because currently we cannot support theme color for this record when reading xls file, so we can only give a color with ARGB=0. For xlsx, we can read those theme colors so we can give [Black] color. For ms excel, it supports to read theme colors from xls file, so when you convert the xls to xlsx again, the theme color is kept. And we also can read the [Black] color from the re-saved xlsx file.We will try to support those theme colors from xls file later when we finish other important tasks. Currently, as workaround we think you can simple compare color’s ARGB value to check whether they are same.

For the formula issue, we did find that the formula saved by ms excel2010 is “=Sheet1!$A$2”(different from the saved xls of excel2007 or lower versions) and so we have to give the same data with what saved in xls file. However, we think it is a bug or at least an incompatibility of excel2010 with other versions. For the excel2010 saved xls, when you open it with ms excel2007 again and edit the conditional formatting, you will find you cannot apply the rule again even if you did not edit anything of the formula. So the formula with sheet reference is invalid for excel97-2007 for conditional formattings.

Thank you for clarification.


Best regards,
Alex Shloma