module Axlsx
xlsx generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx
excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.
<xsd:complexType name=“CT_DefinedName”>
<xsd:simpleContent>
 <xsd:extension base=“ST_Formula”>
<xsd:attribute name="name" type="s:ST_Xstring" use="required"/> <xsd:attribute name="comment" type="s:ST_Xstring" use="optional"/> <xsd:attribute name="customMenu" type="s:ST_Xstring" use="optional"/> <xsd:attribute name="description" type="s:ST_Xstring" use="optional"/> <xsd:attribute name="help" type="s:ST_Xstring" use="optional"/> <xsd:attribute name="statusBar" type="s:ST_Xstring" use="optional"/> <xsd:attribute name="localSheetId" type="xsd:unsignedInt" use="optional"/> <xsd:attribute name="hidden" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="function" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="vbProcedure" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="xlm" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="functionGroupId" type="xsd:unsignedInt" use="optional"/> <xsd:attribute name="shortcutKey" type="s:ST_Xstring" use="optional"/> <xsd:attribute name="publishToServer" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="workbookParameter" type="xsd:boolean" use="optional" default="false"/> </xsd:extenstion> </xsd:simpleContent>
<xsd:complexType name=“CT_BookView”>
<xsd:sequence> <xsd:element name="extLst" type="CT_ExtensionList" minOccurs="0" maxOccurs="1"/> </xsd:sequence> <xsd:attribute name="visibility" type="ST_Visibility" use="optional" default="visible"/> <xsd:attribute name="minimized" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="showHorizontalScroll" type="xsd:boolean" use="optional" default="true"/> <xsd:attribute name="showVerticalScroll" type="xsd:boolean" use="optional" default="true"/> <xsd:attribute name="showSheetTabs" type="xsd:boolean" use="optional" default="true"/> <xsd:attribute name="xWindow" type="xsd:int" use="optional"/> <xsd:attribute name="yWindow" type="xsd:int" use="optional"/> <xsd:attribute name="windowWidth" type="xsd:unsignedInt" use="optional"/> <xsd:attribute name="windowHeight" type="xsd:unsignedInt" use="optional"/> <xsd:attribute name="tabRatio" type="xsd:unsignedInt" use="optional" default="600"/> <xsd:attribute name="firstSheet" type="xsd:unsignedInt" use="optional" default="0"/> <xsd:attribute name="activeTab" type="xsd:unsignedInt" use="optional" default="0"/> <xsd:attribute name="autoFilterDateGrouping" type="xsd:boolean" use="optional" default="true"/>
</xsd:complexType>
Constants
- APP_CT
app content type
- APP_NS
extended-properties namespace
- APP_NS_VT
doc props namespace
- APP_PN
app part
- APP_R
app rels namespace
- APP_XSD
App
validation schema- CHART_CT
chart content type
- CHART_PN
chart part
- CHART_R
chart rels namespace
- COMMENT_CT
comments content type
- COMMENT_PN
comment part
- COMMENT_R
comment rels namespace
- COMMENT_R_NULL
comment relation for nil target
- CONTENT_TYPES_PN
content types part
- CONTENT_TYPES_XSD
content types validation schema
- CONTROL_CHARS
The regular expression used to remove control characters from worksheets
- CORE_CT
core content type
- CORE_NS
core properties namespace
- CORE_NS_DC
dc elements (core) namespace
- CORE_NS_DCMIT
dcmit (core) namespcace
- CORE_NS_DCT
dc terms namespace
- CORE_NS_XSI
xml schema namespace
- CORE_PN
core part
- CORE_R
core rels namespace
- CORE_XSD
core validation schema
- DIGITAL_SIGNATURE_CERTIFICATE_CT
digital signature certificate content type
- DIGITAL_SIGNATURE_NS
Digital signature namespace
- DIGITAL_SIGNATURE_ORIGIN_CT
digital signature origin content type
- DIGITAL_SIGNATURE_R
digital signature rels namespace
- DIGITAL_SIGNATURE_XML_CT
digital signature xml content type
- DRAWING_CT
drawing content type
- DRAWING_PN
drawing part
- DRAWING_R
drawing rels namespace
- DRAWING_RELS_PN
drawing rels part
- DRAWING_XSD
drawing validation schema
- ENCODING
XML Encoding
- ERR_ANGLE
error message for invalid angles
- ERR_DUPLICATE_SHEET_NAME
error message for duplicate sheet names
- ERR_INTEGERISH
error message for non 'integerish' value
- ERR_INVALID_BORDER_ID
error message for invalid border id reference
- ERR_INVALID_BORDER_OPTIONS
error message when user does not provide color and or style options for border in Style#add_sytle
- ERR_RANGE
error message for
RangeValidator
- ERR_REGEX
error message for
RegexValidator
- ERR_RESTRICTION
error messages RestrictionValidor
- ERR_SHEET_NAME_CHARACTER_FORBIDDEN
error message for sheets that use a name which include invalid characters
- ERR_SHEET_NAME_TOO_LONG
error message for sheets that use a name which is longer than 31 bytes
- ERR_TYPE
error message
DataTypeValidator
- GIF_CT
gif content type
- GIF_EX
gif extension
- HYPERLINK_R
hyperlink rels namespace
- IMAGE_PN
chart part
- IMAGE_R
image rels namespace
- ISO_8601_REGEX
ISO 8601 date recognition
- JPEG_CT
jpeg content type
- JPEG_EX
jpeg extension
- MAYBE_FLOAT_REGEX
- NUMERIC_REGEX
Numeric recognition
- NUM_FMT_PERCENT
number format id for pecentage formatting using the default formatting id.
- NUM_FMT_YYYYMMDD
number format id for date format like 2011/11/13
- NUM_FMT_YYYYMMDDHHMMSS
number format id for time format the creates 2011/11/13 12:23:10
- PIVOT_TABLE_CACHE_DEFINITION_CT
pivot table cache definition content type
- PIVOT_TABLE_CACHE_DEFINITION_PN
pivot table cache definition part name
- PIVOT_TABLE_CACHE_DEFINITION_R
pivot table cache definition namespace
- PIVOT_TABLE_CT
pivot table content type
- PIVOT_TABLE_PN
pivot table parts
- PIVOT_TABLE_R
pivot table rels namespace
- PIVOT_TABLE_RELS_PN
pivot table rels parts
- PNG_CT
png content type
- PNG_EX
png extension
- RELS_CT
rels content type
- RELS_EX
rels content type extension
- RELS_PN
rels part
- RELS_R
relationships name space
- RELS_XSD
rels validation schema
- SAFE_FLOAT_REGEX
FLOAT recognition
- SCHEMA_BASE
location of schema files for validation
- SHARED_STRINGS_CT
shared strings content type
- SHARED_STRINGS_PN
shared_strings part
- SHARED_STRINGS_R
shared strings namespace
- SML_XSD
spreadsheetML validation schema
- STYLES_CT
styles content type
- STYLES_PN
styles part
- STYLES_R
styles rels namespace
- STYLE_DATE
cellXfs id for default date styling
- STYLE_THIN_BORDER
cellXfs id for thin borders around the cell
- TABLE_CT
table content type
- TABLE_PN
drawing part
- TABLE_R
table rels namespace
- UINT_VALIDATOR
Validates an unsigned intger
- VERSION
The current version
- VML_DRAWING_CT
VML
Drawing
content type- VML_DRAWING_PN
vml drawing part
- VML_DRAWING_R
vml drawing relation namespace
- WORKBOOK_CT
workbook content type
- WORKBOOK_PN
workbook part
- WORKBOOK_R
workbook rels namespace
- WORKBOOK_RELS_PN
workbook rels part
- WORKSHEET_CT
worksheet content type
- WORKSHEET_PN
worksheet part
- WORKSHEET_R
worksheet rels namespace
- WORKSHEET_RELS_PN
worksheet rels part
- XML_CT
xml content type
- XML_EX
xml content type extensions
- XML_NS
spreadsheetML namespace
- XML_NS_A
drawing namespace
- XML_NS_C
chart namespace
- XML_NS_R
relationships namespace
- XML_NS_T
content-types namespace
- XML_NS_XDR
spreadsheet drawing namespace
Public Class Methods
If value is boolean return 1 or 0 else return the value @param [Object] value The value to process @return [Object]
# File lib/axlsx.rb, line 149 def self.booleanize(value) if value == true || value == false value ? 1 : 0 else value end end
performs the increadible feat of changing snake_case to CamelCase @param [String] s The snake case string to camelize @return [String]
# File lib/axlsx.rb, line 126 def self.camel(s="", all_caps = true) s = s.to_s s = s.capitalize if all_caps s.gsub(/_(.)/){ $1.upcase } end
@return [String] The alpha(column)numeric(row) reference for this sell. @example Relative Cell
Reference
ws.rows.first.cells.first.r #=> "A1"
# File lib/axlsx.rb, line 105 def self.cell_r(c_index, r_index) col_ref(c_index) << (r_index+1).to_s end
determines the cell range for the items provided
# File lib/axlsx.rb, line 52 def self.cell_range(cells, absolute=true) return "" unless cells.first.is_a? Cell cells = sort_cells(cells) reference = "#{cells.first.reference(absolute)}:#{cells.last.reference(absolute)}" if absolute escaped_name = cells.first.row.worksheet.name.gsub ''', "''" "'#{escaped_name}'!#{reference}" else reference end end
global reference html entity encoding
@return [HtmlEntities]
# File lib/axlsx.rb, line 74 def self.coder @@coder ||= ::HTMLEntities.new end
converts the column index into alphabetical values. @note This follows the standard spreadsheet convention of naming columns A to Z, followed by AA to AZ etc. @return [String]
# File lib/axlsx.rb, line 91 def self.col_ref(index) chars = '' while index >= 26 do index, char = index.divmod(26) chars.prepend((char + 65).chr) index -= 1 end chars.prepend((index + 65).chr) chars end
returns the x, y position of a cell
# File lib/axlsx.rb, line 79 def self.name_to_indices(name) raise ArgumentError, 'invalid cell name' unless name.size > 1 # capitalization?!? v = name[/[A-Z]+/].reverse.chars.reduce({:base=>1, :i=>0}) do |val, c| val[:i] += ((c.bytes.first - 64) * val[:base]); val[:base] *= 26; val end [v[:i]-1, ((name[/[1-9][0-9]*/]).to_i)-1] end
Creates an array of individual cell references based on an excel reference range. @param [String] range A cell range, for example A1:D5 @return [Array]
# File lib/axlsx.rb, line 112 def self.range_to_a(range) range.match(/^(\w+?\d+)\:(\w+?\d+)$/) start_col, start_row = name_to_indices($1) end_col, end_row = name_to_indices($2) (start_row..end_row).to_a.map do |row_num| (start_col..end_col).to_a.map do |col_num| cell_r(col_num, row_num) end end end
returns the provided string with all invalid control charaters removed. @param [String] str The string to process @return [String]
# File lib/axlsx.rb, line 136 def self.sanitize(str) if str.frozen? str.delete(CONTROL_CHARS) else str.delete!(CONTROL_CHARS) str end end
sorts the array of cells provided to start from the minimum x,y to the maximum x.y# @param [Array] cells @return [Array]
# File lib/axlsx.rb, line 68 def self.sort_cells(cells) cells.sort { |x, y| [x.index, x.row.row_index] <=> [y.index, y.row.row_index] } end
Instructs the serializer to not try to escape cell value input. This will give you a huge speed bonus, but if you content has <, > or other xml character data the workbook will be invalid and excel will complain.
# File lib/axlsx.rb, line 160 def self.trust_input @trust_input ||= false end
@param trust_me A boolean value indicating if the cell value content is to be trusted @return [Boolean] @see Axlsx::trust_input
# File lib/axlsx.rb, line 167 def self.trust_input=(trust_me) @trust_input = trust_me end
Requires that the value is between -54000000 and 54000000 @param [Any] v The value validated @raise [ArgumentError] raised if the value cannot be converted to an integer between the allowed angle values for chart label rotation. @return [Boolean] true if the data is valid
# File lib/axlsx/util/validators.rb, line 78 def self.validate_angle(v) raise ArgumentError, (ERR_ANGLE % v.inspect) unless (v.to_i >= -5400000 && v.to_i <= 5400000) end
Requires that the value is a form that can be evaluated as a boolean in an xml document. The value must be an instance of String, Integer, Symbol, TrueClass or FalseClass and it must be one of 0, 1, “true”, “false”, :true, :false, true, false, “0”, or “1” @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 111 def self.validate_boolean(v) DataTypeValidator.validate(:boolean, [String, Integer, Symbol, TrueClass, FalseClass], v, lambda { |arg| [0, 1, "true", "false", :true, :false, true, false, "0", "1"].include?(arg) }) end
Requires that the value is one of :none, :single, :double, :singleAccounting, :doubleAccounting
# File lib/axlsx/util/validators.rb, line 148 def self.validate_cell_u(v) RestrictionValidator.validate "cell run style u", [:none, :single, :double, :singleAccounting, :doubleAccounting], 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
# File lib/axlsx/util/validators.rb, line 200 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 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
# File lib/axlsx/util/validators.rb, line 185 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 thatt he value is a valid conditional formatting value object type. valid types must be one of num, percent, max, min, formula and percentile
# File lib/axlsx/util/validators.rb, line 191 def self.validate_conditional_formatting_value_object_type(v) RestrictionValidator.validate :conditional_formatting_value_object_type, [:num, :percent, :max, :min, :formula, :percentile], v end
Requires that the value is a valid content_type TABLE_CT
, WORKBOOK_CT
, APP_CT
, RELS_CT
, STYLES_CT
, XML_CT
, WORKSHEET_CT
, SHARED_STRINGS_CT
, CORE_CT
, CHART_CT
, DRAWING_CT
, COMMENT_CT
are allowed @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 235 def self.validate_content_type(v) RestrictionValidator.validate :content_type, [TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, JPEG_CT, GIF_CT, PNG_CT, DRAWING_CT, COMMENT_CT, VML_DRAWING_CT, PIVOT_TABLE_CT, PIVOT_TABLE_CACHE_DEFINITION_CT], v end
Requires that the value is a valid data_validation_error_style :information, :stop, :warning @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 256 def self.validate_data_validation_error_style(v) RestrictionValidator.validate :validate_data_validation_error_style, [:information, :stop, :warning], v end
Requires that the value is valid data validation operator. valid operators must be one of lessThan, lessThanOrEqual, equal, notEqual, greaterThanOrEqual, greaterThan, between, notBetween @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 264 def self.validate_data_validation_operator(v) RestrictionValidator.validate :data_validation_operator, [:lessThan, :lessThanOrEqual, :equal, :notEqual, :greaterThanOrEqual, :greaterThan, :between, :notBetween], v end
Requires that the value is valid data validation type. valid types must be one of custom, data, decimal, list, none, textLength, time, whole @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 271 def self.validate_data_validation_type(v) RestrictionValidator.validate :data_validation_type, [:custom, :data, :decimal, :list, :none, :textLength, :date, :time, :whole], v end
Requires that the value is a valid “display blanks as” type. valid types must be one of gap, span, zero @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 299 def self.validate_display_blanks_as(v) RestrictionValidator.validate :display_blanks_as, [:gap, :span, :zero], v end
validates cell style family which must be between 1 and 5
# File lib/axlsx/util/validators.rb, line 153 def self.validate_family(v) RestrictionValidator.validate "cell run style family", 1..5, v end
Requires that the value is a Float @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 123 def self.validate_float(v) DataTypeValidator.validate :float, Float, v end
Requires that the value is a gradient_type. valid types are :linear and :path @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 207 def self.validate_gradient_type(v) RestrictionValidator.validate :gradient_type, [:linear, :path], v end
Requires that the value is a valid horizontal_alignment :general, :left, :center, :right, :fill, :justify, :centerContinuous, :distributed are allowed @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 221 def self.validate_horizontal_alignment(v) RestrictionValidator.validate :horizontal_alignment, [:general, :left, :center, :right, :fill, :justify, :centerContinuous, :distributed], v end
Requires that the value is one of the valid ST_IconSet types Allowed values are: 3Arrows, 3ArrowsGray, 3Flags, 3TrafficLights1, 3TrafficLights2, 3Signs, 3Symbols, 3Symbols2, 4Arrows, 4ArrowsGray, 4RedToBlack, 4Rating, 4TrafficLights, 5Arrows, 5ArrowsGray, 5Rating, 5Quarters
# File lib/axlsx/util/validators.rb, line 174 def self.validate_icon_set(v) RestrictionValidator.validate :iconSet, ["3Arrows", "3ArrowsGray", "3Flags", "3TrafficLights1", "3TrafficLights2", "3Signs", "3Symbols", "3Symbols2", "4Arrows", "4ArrowsGray", "4RedToBlack", "4Rating", "4TrafficLights", "5Arrows", "5ArrowsGray", "5Rating", "5Quarters"], v end
Requires that the value is a Integer @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 103 def self.validate_int(v) DataTypeValidator.validate :signed_int, Integer, v end
Requires that the value can be converted to an integer @para, [Any] v the value to validate @raise [ArgumentError] raised if the value cannot be converted to an integer
# File lib/axlsx/util/validators.rb, line 70 def self.validate_integerish(v) raise ArgumentError, (ERR_INTEGERISH % v.inspect) unless (v.respond_to?(:to_i) && v.to_i.is_a?(Integer)) end
Requires that the value is one of :default, :circle, :dash, :diamond, :dot, :picture, :plus, :square, :star, :triangle, :x
# File lib/axlsx/util/validators.rb, line 309 def self.validate_marker_symbol(v) RestrictionValidator.validate :marker_symbol, [:default, :circle, :dash, :diamond, :dot, :picture, :plus, :square, :star, :triangle, :x], v end
Requires that the value is a string containing a positive decimal number followed by one of the following units: “mm”, “cm”, “in”, “pt”, “pc”, “pi”
# File lib/axlsx/util/validators.rb, line 129 def self.validate_number_with_unit(v) RegexValidator.validate "number_with_unit", /\A[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)\Z/, v end
Requires that the value is one of :default, :landscape, or :portrait.
# File lib/axlsx/util/validators.rb, line 144 def self.validate_page_orientation(v) RestrictionValidator.validate "page_orientation", [:default, :landscape, :portrait], v end
Requires that the value is a valid active pane type. valid types must be one of bottom_left, bottom_right, top_left, top_right @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 285 def self.validate_pane_type(v) RestrictionValidator.validate :active_pane_type, [:bottom_left, :bottom_right, :top_left, :top_right], v end
Requires that the value is valid pattern type. valid pattern types must be one of :none, :solid, :mediumGray, :darkGray, :lightGray, :darkHorizontal, :darkVertical, :darkDown, :darkUp, :darkGrid, :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, or :gray0625. @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 160 def self.validate_pattern_type(v) RestrictionValidator.validate :pattern_type, [:none, :solid, :mediumGray, :darkGray, :lightGray, :darkHorizontal, :darkVertical, :darkDown, :darkUp, :darkGrid, :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, :gray0625], v end
Requires that the value is a valid relationship_type XML_NS_R
, TABLE_R
, WORKBOOK_R
, WORKSHEET_R
, APP_R
, RELS_R
, CORE_R
, STYLES_R
, CHART_R
, DRAWING_R
, IMAGE_R
, HYPERLINK_R
, SHARED_STRINGS_R
are allowed @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 242 def self.validate_relationship_type(v) RestrictionValidator.validate :relationship_type, [XML_NS_R, TABLE_R, WORKBOOK_R, WORKSHEET_R, APP_R, RELS_R, CORE_R, STYLES_R, CHART_R, DRAWING_R, IMAGE_R, HYPERLINK_R, SHARED_STRINGS_R, COMMENT_R, VML_DRAWING_R, COMMENT_R_NULL, PIVOT_TABLE_R, PIVOT_TABLE_CACHE_DEFINITION_R], v end
Requires that the value is an integer ranging from 10 to 400 or 0.
# File lib/axlsx/util/validators.rb, line 139 def self.validate_scale_0_10_400(v) DataTypeValidator.validate "page_scale", Integer, v, lambda { |arg| arg == 0 || (arg >= 10 && arg <= 400) } end
Requires that the value is an integer ranging from 10 to 400.
# File lib/axlsx/util/validators.rb, line 134 def self.validate_scale_10_400(v) DataTypeValidator.validate "page_scale", Integer, v, lambda { |arg| arg >= 10 && arg <= 400 } end
Requires that the value is a valid scatterStyle must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker must be one of “none” | “line” | “lineMarker” | “marker” | “smooth” | “smoothMarker” @param [Symbol|String] v the value to validate
# File lib/axlsx/util/validators.rb, line 215 def self.validate_scatter_style(v) Axlsx::RestrictionValidator.validate "ScatterChart.scatterStyle", [:none, :line, :lineMarker, :marker, :smooth, :smoothMarker], v.to_sym end
Requires that the value is a valid sheet view type. valid types must be one of normal, page_break_preview, page_layout @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 278 def self.validate_sheet_view_type(v) RestrictionValidator.validate :sheet_view_type, [:normal, :page_break_preview, :page_layout], v end
Requires that the value is a valid split state type. valid types must be one of frozen, frozen_split, split @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 292 def self.validate_split_state_type(v) RestrictionValidator.validate :split_state_type, [:frozen, :frozen_split, :split], v end
Requires that the value is a String @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 117 def self.validate_string(v) DataTypeValidator.validate :string, String, v end
Requires that the value is a valid table element type :wholeTable, :headerRow, :totalRow, :firstColumn, :lastColumn, :firstRowStripe, :secondRowStripe, :firstColumnStripe, :secondColumnStripe, :firstHeaderCell, :lastHeaderCell, :firstTotalCell, :lastTotalCell, :firstSubtotalColumn, :secondSubtotalColumn, :thirdSubtotalColumn, :firstSubtotalRow, :secondSubtotalRow, :thirdSubtotalRow, :blankRow, :firstColumnSubheading, :secondColumnSubheading, :thirdColumnSubheading, :firstRowSubheading, :secondRowSubheading, :thirdRowSubheading, :pageFieldLabels, :pageFieldValues are allowed @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 249 def self.validate_table_element_type(v) RestrictionValidator.validate :table_element_type, [:wholeTable, :headerRow, :totalRow, :firstColumn, :lastColumn, :firstRowStripe, :secondRowStripe, :firstColumnStripe, :secondColumnStripe, :firstHeaderCell, :lastHeaderCell, :firstTotalCell, :lastTotalCell, :firstSubtotalColumn, :secondSubtotalColumn, :thirdSubtotalColumn, :firstSubtotalRow, :secondSubtotalRow, :thirdSubtotalRow, :blankRow, :firstColumnSubheading, :secondColumnSubheading, :thirdColumnSubheading, :firstRowSubheading, :secondRowSubheading, :thirdRowSubheading, :pageFieldLabels, :pageFieldValues], 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
# File lib/axlsx/util/validators.rb, line 168 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 a Integer and is greater or equal to 0 @param [Any] v The value validated @raise [ArgumentError] raised if the value is not a Integer value greater or equal to 0 @return [Boolean] true if the data is valid
# File lib/axlsx/util/validators.rb, line 89 def self.validate_unsigned_int(v) DataTypeValidator.validate(:unsigned_int, Integer, v, UINT_VALIDATOR) end
Requires that the value is a Integer or Float and is greater or equal to 0 @param [Any] v The value validated @raise [ArgumentError] raised if the value is not a Integer, Float value greater or equal to 0 @return [Boolean] true if the data is valid
# File lib/axlsx/util/validators.rb, line 97 def self.validate_unsigned_numeric(v) DataTypeValidator.validate(:unsigned_numeric, Numeric, v, UINT_VALIDATOR) end
Requires that the value is a valid vertical_alignment :top, :center, :bottom, :justify, :distributed are allowed @param [Any] v The value validated
# File lib/axlsx/util/validators.rb, line 228 def self.validate_vertical_alignment(v) RestrictionValidator.validate :vertical_alignment, [:top, :center, :bottom, :justify, :distributed], v end
Requires that the value is one of :visible, :hidden, :very_hidden
# File lib/axlsx/util/validators.rb, line 304 def self.validate_view_visibility(v) RestrictionValidator.validate :visibility, [:visible, :hidden, :very_hidden], v end