Class: Axlsx::SheetData

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/sheet_data.rb

Overview

This class manages the serialization of rows for worksheets

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ SheetData

Creates a new SheetData object

Parameters:

  • worksheet (Worksheet)

    The worksheet that owns this sheet data.

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/axlsx/workbook/worksheet/sheet_data.rb', line 8

def initialize(worksheet)
  raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)

  @worksheet = worksheet
end

Instance Attribute Details

#worksheetObject (readonly)

Returns the value of attribute worksheet.



14
15
16
# File 'lib/axlsx/workbook/worksheet/sheet_data.rb', line 14

def worksheet
  @worksheet
end

Instance Method Details

#to_xml_string(str = +'')) ⇒ String

Serialize the sheet data

Parameters:

  • str (String) (defaults to: +''))

    the string this objects serializaton will be concacted to.

Returns:

  • (String)


19
20
21
22
23
24
25
# File 'lib/axlsx/workbook/worksheet/sheet_data.rb', line 19

def to_xml_string(str = +'')
  str << '<sheetData>'
  worksheet.rows.each_with_index do |row, index|
    row.to_xml_string(index, str)
  end
  str << '</sheetData>'
end