I would like to apply ‘Color Scale’ conditional formatting to a range and am having some problems. I begin by placing a datatable of data into the sheet like this:
int idx = conds.AddCondition(FormatConditionType.ColorScale);
FormatCondition cond = conds[idx];
cond.ColorScale.MidCfvo = null;
cond.ColorScale.MinColor = Color.Gold;
cond.ColorScale.MaxColor = Color.SkyBlue;
However it says ‘The name ‘GetFormatCondition’ does not exist in the current context.’ I’ve downloaded and referenced the latest build of the Aspose.Cells DLL zip file and it does not help. The closes I can see is in the ‘Cell’ object, a method called GetFormatConditions. Also the cond.ColorScale.MidCfvo is not recognised.
My desire is as follows:
a) Identify the range the ImportDatatable method used to place its data
b) Exclude the top row (headers), leftmost and rightmost columns, then apply ‘color scale’ conditional formatting to the remaining range.
Well, GetFormatCondition is just a custom method in the document/article that adds a new conditional formatting based on the provided cells area range, it also calls other custom methods in it e.g. FillCell, GetCellAreaByName etc. for applying cells’ shading color and calculate the area etc - these are just user defined custom methods and not the methods of Aspose.Cells API although the code segment used in these methods utilizes Aspose.Cells APIs regarding conditional formattings, see the screen shot below for your reference:
http://prntscr.com/5vxhwy
Moreover, Cells.ImportDataTable can return the Total number of rows imported, so you may get it into some variable object. For getting total number of columns, you may easily use DataTable.Columns.Count attribute for your needs. If you need to get the table range, you may easily evaluate it by yourself. For example you start importing the DataTable into A1 cell, so you may evaluate the starting cell to calculate the indexes (0 based) of the end cell for your requirements by yourself:
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.