diff options
Diffstat (limited to 'lib/axlsx/workbook/worksheet/worksheet_comments.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet_comments.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb new file mode 100644 index 00000000..25ddb024 --- /dev/null +++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb @@ -0,0 +1,38 @@ +module Axlsx + + #A wraper class for comments that defines its on worksheet + #serailization + class WorksheetComments + + def initialize(worksheet) + raise ArugumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet) + @worksheet = worksheet + end + attr_reader :worksheet + + def comments + @comments ||= Comments.new(worksheet) + end + + def add_comment(options={}) + comments.add_comment(options) + end + + def relationships + return [] unless has_comments? + comments.relationships + end + + def has_comments? + !comments.empty? + end + + def index + worksheet.relationships.index { |r| r.Type == VML_DRAWING_R } + 1 + end + def to_xml_string(str = '') + return unless has_comments? + str << "<legacyDrawing r:id='rId#{index}' />" + end + end +end |
