class Rspreadsheet::WorkbookFlat
Constants
- FLAT_TEMPLATE_FILE_NAME
Public Class Methods
new(afilename=nil)
click to toggle source
# File lib/rspreadsheet/workbook.rb, line 193 def initialize(afilename=nil) @worksheets=[] @filename = afilename @xml_doc = LibXML::XML::Document.file(@filename || FLAT_TEMPLATE_FILE_NAME) @xmlnode = @xml_doc.find_first('//office:spreadsheet') @xmlnode.find('./table:table').each do |node| create_worksheet_from_node(node) end end
Public Instance Methods
flat_format?()
click to toggle source
# File lib/rspreadsheet/workbook.rb, line 221 def flat_format?; true end
normal_format?()
click to toggle source
# File lib/rspreadsheet/workbook.rb, line 222 def normal_format?; false end
save(io=nil)
click to toggle source
# File lib/rspreadsheet/workbook.rb, line 203 def save(io=nil) case when @filename.nil? && io.nil? raise 'New file should be named on first save, please provide filename (or IO).' when @filename.kind_of?(String) && io.nil? @xml_doc.save(@filename) when (@filename.kind_of?(String) && (io.kind_of?(String) || io.kind_of?(File))) @filename = (io.kind_of?(File)) ? io.path : io @xml_doc.save(@filename) when io.kind_of?(IO) || io.kind_of?(String) || io.kind_of?(StringIO) IO.write(io,@xml_doc.to_s) io.rewind if io.kind_of?(StringIO) else raise 'Invalid combinations of parameter types in save' end end
Also aliased as: save_to_io, save_as