summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-08-02 23:37:39 +0900
committerRandy Morgan <[email protected]>2012-08-02 23:37:39 +0900
commitacc890d52089dbf18ac3d56bace3a393d195eb9c (patch)
tree5b5cbfa33d0f1ff4e416eb8cac997d4f924142a9
parentb6c50cde41d0ecbd51d56823c84b264523e32a34 (diff)
downloadcaxlsx-acc890d52089dbf18ac3d56bace3a393d195eb9c.tar.gz
caxlsx-acc890d52089dbf18ac3d56bace3a393d195eb9c.zip
hmm…. ditch red carpet and do some docs
-rw-r--r--Rakefile6
-rw-r--r--axlsx.gemspec2
-rw-r--r--lib/axlsx.rb4
-rw-r--r--lib/axlsx/drawing/chart.rb1
-rw-r--r--lib/axlsx/workbook/defined_name.rb3
-rw-r--r--lib/axlsx/workbook/defined_names.rb6
-rw-r--r--lib/axlsx/workbook/worksheet/auto_filter.rb11
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb5
-rw-r--r--lib/axlsx/workbook/worksheet/dimension.rb18
-rw-r--r--lib/axlsx/workbook/worksheet/merged_cells.rb10
10 files changed, 60 insertions, 6 deletions
diff --git a/Rakefile b/Rakefile
index bf6fe7d0..227ecfc2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -9,9 +9,9 @@ task :benchmark do
end
task :gendoc do
- puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
- # system "yardoc"
- # system "yard stats --list-undoc"
+ #puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
+ system "yardoc"
+ system "yard stats --list-undoc"
end
task :test do
diff --git a/axlsx.gemspec b/axlsx.gemspec
index 7e7a1c96..0ff87ae8 100644
--- a/axlsx.gemspec
+++ b/axlsx.gemspec
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
# This has been removed until JRuby can support the native extensions for redcarpet or yard removes the dependency
s.add_development_dependency 'yard'
- s.add_development_dependency 'redcarpet', '~>1.17.2'
+# s.add_development_dependency 'redcarpet', '~>1.17.2'
s.add_development_dependency 'cover_me' unless RUBY_VERSION == '1.8.7'
s.required_ruby_version = '>= 1.8.7'
s.require_path = 'lib'
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index ad14cd7a..50f34c70 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -48,6 +48,10 @@ module Axlsx
absolute ? "'#{cells.first.row.worksheet.name}'!#{reference}" : reference
end
+ # sorts the array of cells provided to start from the minimum x,y to
+ # the maximum x.y#
+ # @param [Array] cells
+ # @return [Array]
def self.sort_cells(cells)
cells.sort { |x, y| [x.index, x.row.index] <=> [y.index, y.row.index] }
end
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index d0c3cd13..8566b3f3 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -196,6 +196,7 @@ module Axlsx
@graphic_frame.anchor.end_at(x, y)
end
+ # sets the view_3D object for the chart
def view_3D=(v) DataTypeValidator.validate "#{self.class}.view_3D", View3D, v; @view_3D = v; end
alias :view3D= :view_3D=
diff --git a/lib/axlsx/workbook/defined_name.rb b/lib/axlsx/workbook/defined_name.rb
index ed4774e8..10a84b3c 100644
--- a/lib/axlsx/workbook/defined_name.rb
+++ b/lib/axlsx/workbook/defined_name.rb
@@ -102,10 +102,13 @@ module Axlsx
end
attr_reader :local_sheet_id
+ # The local sheet index (0-based)
+ # @param [Integer] value the unsinged integer index of the sheet this defined_name applies to.
def local_sheet_id=(value)
Axlsx::validate_unsigned_int(value)
@local_sheet_id = value
end
+
# string attributes that will be added when this class is evaluated
STRING_ATTRIBUTES = [:short_cut_key, :status_bar, :help, :description, :custom_menu, :comment]
diff --git a/lib/axlsx/workbook/defined_names.rb b/lib/axlsx/workbook/defined_names.rb
index 88a8b85f..fd7800a3 100644
--- a/lib/axlsx/workbook/defined_names.rb
+++ b/lib/axlsx/workbook/defined_names.rb
@@ -1,11 +1,15 @@
module Axlsx
-
+ # a simple types list of DefinedName objects
class DefinedNames < SimpleTypedList
+ # creates the DefinedNames object
def initialize
super DefinedName
end
+ # Serialize to xml
+ # @param [String] str
+ # @return [String]
def to_xml_string(str = '')
return if @list.empty?
str << "<definedNames>"
diff --git a/lib/axlsx/workbook/worksheet/auto_filter.rb b/lib/axlsx/workbook/worksheet/auto_filter.rb
index f2197c37..efc6e942 100644
--- a/lib/axlsx/workbook/worksheet/auto_filter.rb
+++ b/lib/axlsx/workbook/worksheet/auto_filter.rb
@@ -2,19 +2,30 @@ module Axlsx
#This class represents an auto filter range in a worksheet
class AutoFilter
+
+ # creates a new Autofilter object
+ # @param [Worksheet] worksheet
def initialize(worksheet)
raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
@worksheet = worksheet
end
attr_reader :worksheet
+
+ # The range the autofilter should be applied to.
+ # This should be a string like 'A1:B8'
+ # @return [String]
attr_accessor :range
+ # the formula for the defined name required for this auto filter
+ # @return [String]
def defined_name
return unless range
Axlsx.cell_range(range.split(':').collect { |name| worksheet.name_to_cell(name)})
end
+ # serialize the object
+ # @return [String]
def to_xml_string(str='')
str << "<autoFilter ref='#{range}'></autoFilter>"
end
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index ad45b70b..ea6746cd 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -331,6 +331,11 @@ module Axlsx
((value.to_s.count(Worksheet.thin_chars) * mdw + 5) / mdw * 256) / 256.0 * font_scale
end
+ # returns the absolute or relative string style reference for
+ # this cell.
+ # @param [Boolean] absolute -when false a relative reference will be
+ # returned.
+ # @return [String]
def reference(absolute=true)
absolute ? r_abs : r
end
diff --git a/lib/axlsx/workbook/worksheet/dimension.rb b/lib/axlsx/workbook/worksheet/dimension.rb
index 838b4ffa..4314b909 100644
--- a/lib/axlsx/workbook/worksheet/dimension.rb
+++ b/lib/axlsx/workbook/worksheet/dimension.rb
@@ -5,16 +5,22 @@ module Axlsx
# LibraOffice require this node to render the sheet
class Dimension
-
+ # the default value for the first cell in the dimension
+ # @return [String]
def self.default_first
@@default_first ||= 'A1'
end
+ # the default value for the last cell in the dimension
+ # @return [String]
def self.default_last
@@default_last ||= 'AA200'
end
+ # Creates a new dimension object
+ # @param[Worksheet] worksheet - the worksheet this dimension applies
+ # to.
def initialize(worksheet)
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
@worksheet = worksheet
@@ -22,25 +28,35 @@ module Axlsx
attr_reader :worksheet
+ # the full refernece for this dimension
+ # @return [String]
def sqref
"#{first_cell_reference}:#{last_cell_reference}"
end
+ # serialize the object
+ # @return [String]
def to_xml_string(str = '')
return if worksheet.rows.empty?
str << "<dimension ref=\"%s\"></dimension>" % sqref
end
+ # The first cell in the dimension
+ # @return [String]
def first_cell_reference
dimension_reference(worksheet.rows.first.cells.first, Dimension.default_first)
end
+ # the last cell in the dimension
+ # @return [String]
def last_cell_reference
dimension_reference(worksheet.rows.last.cells.last, Dimension.default_last)
end
private
+ # Returns the reference of a cell or the default specified
+ # @return [String]
def dimension_reference(cell, default)
return default unless cell.respond_to?(:r)
cell.r
diff --git a/lib/axlsx/workbook/worksheet/merged_cells.rb b/lib/axlsx/workbook/worksheet/merged_cells.rb
index 943cab04..8850e295 100644
--- a/lib/axlsx/workbook/worksheet/merged_cells.rb
+++ b/lib/axlsx/workbook/worksheet/merged_cells.rb
@@ -1,12 +1,19 @@
module Axlsx
+ # A simple list of merged cells
class MergedCells < SimpleTypedList
+ # creates a new MergedCells object
+ # @param [Worksheet] worksheet
def initialize(worksheet)
raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
super String
end
+ # adds cells to the merged cells collection
+ # @param [Array||String] cells The cells to add to the merged cells
+ # collection. This can be an array of actual cells or a string style
+ # range like 'A1:C1'
def add(cells)
@list << if cells.is_a?(String)
cells
@@ -15,6 +22,9 @@ module Axlsx
end
end
+ # serialize the object
+ # @param [String] str
+ # @return [String]
def to_xml_string(str = '')
return if @list.empty?
str << "<mergeCells count='#{size}'>"