summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util
diff options
context:
space:
mode:
authorStephen Pike <[email protected]>2012-04-19 21:23:13 -0400
committerStephen Pike <[email protected]>2012-04-20 15:09:50 -0400
commitcb5fb866eefeaacb99dafb22b703224a480350ff (patch)
tree8879f6d63760326c0ab7e3245933d32a1225ae5a /lib/axlsx/util
parentfc8c56f9e1455332f6c3f10775cd11a0910b3476 (diff)
downloadcaxlsx-cb5fb866eefeaacb99dafb22b703224a480350ff.tar.gz
caxlsx-cb5fb866eefeaacb99dafb22b703224a480350ff.zip
# Support for conditional formatting
Adds support for conditional formatting via two new classes, ConditionalFormatting and ConditionalFormattingRule. Conditional Formats apply to ranges of cells, and can include multiple rules, ranked by priority. A single worksheet has many @conditional_formattings applied to different ranges. There are still pieces of the spec missing from the implementation. The biggest glaring ommission are the child elements colorScale, dataBar, and iconSet (I only implemented formula). http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.conditionalformattingrule.aspx
Diffstat (limited to 'lib/axlsx/util')
-rw-r--r--lib/axlsx/util/validators.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb
index 54a0aeb4..14d34d36 100644
--- a/lib/axlsx/util/validators.rb
+++ b/lib/axlsx/util/validators.rb
@@ -96,6 +96,35 @@ module Axlsx
:darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, :gray0625], v
end
+ # Requires that the value is one of the ST_TimePeriod types
+ # valid time period types are today, yesterday, tomorrow, last7Days,
+ # thisMonth, lastMonth, nextMonth, thisWeek, lastWeek, nextWeek
+ def self.validate_time_period_type(v)
+ RestrictionValidator.validate :time_period_type, [:today, :yesterday, :tomorrow, :last7Days, :thisMonth, :lastMonth, :nextMonth, :thisWeek, :lastWeek, :nextWeek], v
+
+
+ end
+
+ # Requires that the value is valid conditional formatting type.
+ # valid types must be one of expression, cellIs, colorScale,
+ # dataBar, iconSet, top10, uniqueValues, duplicateValues,
+ # containsText, notContainsText, beginsWith, endsWith,
+ # containsBlanks, notContainsBlanks, containsErrors,
+ # notContainsErrors, timePeriod, aboveAverage
+ # @param [Any] v The value validated
+ def self.validate_conditional_formatting_type(v)
+ RestrictionValidator.validate :conditional_formatting_type, [:expression, :cellIs, :colorScale, :dataBar, :iconSet, :top10, :uniqueValues, :duplicateValues, :containsText, :notContainsText, :beginsWith, :endsWith, :containsBlanks, :notContainsBlanks, :containsErrors, :notContainsErrors, :timePeriod, :aboveAverage], v
+ end
+
+ # Requires that the value is valid conditional formatting operator.
+ # valid operators must be one of lessThan, lessThanOrEqual, equal,
+ # notEqual, greaterThanOrEqual, greaterThan, between, notBetween,
+ # containsText, notContains, beginsWith, endsWith
+ # @param [Any] v The value validated
+ def self.validate_conditional_formatting_operator(v)
+ RestrictionValidator.validate :conditional_formatting_type, [:lessThan, :lessThanOrEqual, :equal, :notEqual, :greaterThanOrEqual, :greaterThan, :between, :notBetween, :containsText, :notContains, :beginsWith, :endsWith], v
+ end
+
# Requires that the value is a gradient_type.
# valid types are :linear and :path
# @param [Any] v The value validated