Module: Workbook::Readers::TxtReader

Included in:
Book
Defined in:
lib/workbook/readers/txt_reader.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) load_txt(text)



5
6
7
8
# File 'lib/workbook/readers/txt_reader.rb', line 5

def load_txt text
  csv = text
  parse_txt csv        
end

- (Object) parse_txt(csv_raw)



10
11
12
13
14
# File 'lib/workbook/readers/txt_reader.rb', line 10

def parse_txt csv_raw
  csv = []
  csv_raw.split("\n").each {|l| csv << FasterCSV.parse_line(l,{:col_sep=>"\t"});nil}
  self[0]=Workbook::Sheet.new(csv,self,{:parse_cells_on_batch_creation=>true, :cell_parse_options=>{:detect_date=>true}}) unless sheet.has_contents?
end