class Xls::Spreadsheet

Overview

A Xls::Spreadsheet represents the document and contains metadata.

Included Modules

Defined in:

xls/helpers/constants.cr
xls/spreadsheet/font.cr
xls/spreadsheet/format.cr
xls/spreadsheet/spreadsheet.cr
xls/spreadsheet/xf.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Xls::InspectableMethods

inspect(io : IO) : Nil inspect, to_s(io : IO) : Nil to_s

Constructor Detail

def self.new(path : Path) #

Creates a new Xls::Spreadsheet by providing a filepath

Throws Xls::FileNotFound if the filepath cannot be found.


[View source]
def self.new(content : String) #

Creates a new Xls::Spreadsheet by providing a string


[View source]
def self.new(io : IO) #

Creates a new Xls::Spreadsheet by providing an IO


[View source]

Class Method Detail

def self.debugging(enable = true, value : UInt32 = 1) : Nil #

Toggles debug mode for libxls

value controls different types of debugging information.


[View source]
def self.open(file_or_content, & : Spreadsheet -> ) #

Yields a new Xls::Spreadsheet by providing a filepath or string or IO

Calls #validate! on the newly created Xls::Spreadsheet.

Always invokes #close after yielding.


[View source]
def self.open_file(path : Path, charset : String = "UTF-8") #

Creates a new Xls::Spreadsheet by opening a file

charset can be an encoding other than UTF-8.

Throws Xls::FileNotFound if the filepath cannot be found.


[View source]
def self.xls_version : String #

Returns libxls version


[View source]

Instance Method Detail

def active_worksheet : Worksheet? #

Returns the active (displayed) worksheet


[View source]
def charset : String #

Returns the encoding of the spreadsheet


[View source]
def close : Nil #

Closes the Xls::Spreadsheet and any Xls::Worksheet's

Once a Xls::Spreadsheet is closed, it cannot be reopened in the same instance. You must create a new Xls::Spreadsheet instance to reopen it.


[View source]
def closed? : Bool #

Checks if the Xls::Spreadsheet is closed


[View source]
def codepage : UInt16 #

Returns the text encoding used to write byte strings, stored as MS Windows code page identifier

For more information see https://en.wikipedia.org/wiki/Character_encoding.


[View source]
def css : String #

Returns CSS for spreadsheet


[View source]
def doc_summary : String #

Returns the Document Summary of the spreadsheet


[View source]
def fonts : Array(Font) #

Returns information about a used font, including character formatting

All FONT records occur together in a sequential list. Other records referencing a FONT record contain an index into this list.

The font with index 4 is omitted in all BIFF versions. This means the first four fonts have zero-based indexes, and the fifth font and all following fonts are refereced with one-based indexes. Use Xls::Spreadsheet::Font#real_index to access this particular sequence.


[View source]
def formats : Array(Format) #

Returns information about a number format

All FORMAT records occur together in a sequential list.


[View source]
def summary : String #

Returns the Summary of the spreadsheet


[View source]
def to_unsafe : Pointer(Xls::LibXls::XlsWorkBook) #

[View source]
def validate! : Nil #

Validates the spreadsheet

Can only be called once.

Throws Xls::Error if spreadsheet is invalid.

Throws Xls::WorkbookParserException if spreadsheet failed to parse.


[View source]
def worksheets : Array(Worksheet) #

Returns worksheets for the spreadsheet

Throws Xls::WorksheetParserException if a worksheet failed to parse.


[View source]
def xfs : Array(Xf) #

Returns formatting information for cells, rows, columns or styles


[View source]