Class: Oxcelix::FormattedWorkbook

Inherits:
Workbook
  • Object
show all
Defined in:
lib/oxcelix/workbook.rb

Overview

FormattedWorkbook is a Workbook that contains the formatted values (strings) of the original Excel cells instead of Cell objects. The values are taken from the Sheet arrays by running the #Cell::to_fmt method. The result will be exactly the same as if you ran the #Sheet::to_fmt method, but it will be snappier as the merged cellgroups will not need to be processed.

Constant Summary

Constants included from Numformats

Numformats::Dtmap, Numformats::Formatarray

Instance Attribute Summary

Attributes inherited from Workbook

#sheets

Instance Method Summary collapse

Methods inherited from Workbook

#commentsrel, #initialize, #matrixto, #mergevalues, #mkcomments, #open, #parse, #sheet_collection, #sheetdata, #shstrings, #unpack

Methods included from Numformats

#add_custom_formats, #datetime, #numeric

Methods included from Workbookhelper

#[]

Methods included from Cellhelper

#x, #y

Constructor Details

This class inherits a constructor from Oxcelix::Workbook

Instance Method Details

#buildsheet(sheet, options) ⇒ Object (private)

A class that represents an Excel workbook. By default, it will open the excel file, and convert it to a collection of Matrix objects


378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/oxcelix/workbook.rb', line 378

def buildsheet(sheet, options)
  ydiff, xdiff = 0,0
  if !options[:paginate].nil?
    ydiff = options[:paginate][0] * (options[:paginate][1]-1)
  elsif !options[:cellrange].nil?
    xdiff = x(options[:cellrange].begin)
    ydiff = y(options[:cellrange].begin)
  end
  m=Sheet.build(sheet[:cells].last.y+1-ydiff, sheet[:cells].last.x+1-xdiff) {nil}
  sheet[:cells].each do |c|
    m[c.y-ydiff, c.x-xdiff] = c.to_fmt
  end
  return m
end