Description

class Axlsx::Workbook

The Workbook class is an xlsx workbook that manages worksheets, charts, drawings and styles. The following parts of the Office Open XML spreadsheet specification are not implimented in this version.

bookViews
calcPr
customWorkbookViews
definedNames
externalReferences
extLst
fileRecoveryPr
fileSharing
fileVersion
functionGroups
oleSize
pivotCaches
smartTagPr
smartTagTypes
webPublishing
webPublishObjects
workbookProtection
workbookPr*

*workbookPr is only supported to the extend of date1904

Creates a new Workbook The recomended way to work with workbooks is via Package#workbook

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • date1904. (Boolean)

    If this is not specified, date1904 is set to false. Office 2011 for Mac defaults to false.

Yields:

  • (_self)

Yield Parameters:

  • _self (Axlsx::Workbook)

    the object that the method was called on

retrieves the date1904 attribute

Sets the date1904 attribute to the provided boolean

returns a range of cells in a worksheet retrieve the cells from. e.g. range('Sheet1!A1:B2') will return an array of four cells [A1, A2, B1, B2] while range('Sheet1!A1') will return a single Cell.

Parameters:

  • cell_def (String)

    The excel style reference defining the worksheet and cells. The range must specify the sheet to

Raises:

  • (ArgumentError)

Adds a defined name to this workbook

Parameters:

  • formula (String)

    @see DefinedName

  • options (Hash)

    @see DefinedName

Adds a worksheet to this workbook

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • name (String)

    The name of the worksheet.

  • page_margins (Hash)

    The page margins for the worksheet.

Yields:

  • (worksheet)
Note:

The recommended way to manage charts is Worksheet#add_chart

A colllection of charts associated with this workbook

Note:

The recommended way to manage comments is WOrksheet#add_comment

A collection of comments associated with this workbook

Instance level access to the class variable 1904

see @date1904

Note:

The recommended way to manage defined names is Workbook#add_defined_name

A collection of defined names for this workbook

Note:

The recommended way to manage drawings is Worksheet#add_chart

A colllection of drawings associated with this workbook

Note:

The recommended way to manage images is Worksheet#add_image

A colllection of images associated with this workbook

inserts a worksheet into this workbook at the position specified. It the index specified is out of range, the worksheet will be added to the end of the worksheets collection

Parameters:

  • index (defaults to: 0)

    The zero based position to insert the newly created worksheet

  • options (Hash) (defaults to: {})

    Options to pass into the worksheed during initialization.

Options Hash (options):

  • name (String)

    The name of the worksheet

  • page_margins (Hash)

    The page margins for the worksheet

Yields:

  • (worksheet)
Note:

The recommended way to manage drawings is Worksheet#add_table

A colllection of pivot tables associated with this workbook

The workbook relationships. This is managed automatically by the workbook

generates a shared string object against all cells in all worksheets.

A quick helper to retrive a worksheet by name

Parameters:

  • name (String)

    The name of the sheet you are looking for

Note:

The recommended way to manage styles is Styles#add_style

The styles associated with this workbook

Yields:

  • (@styles)
Note:

The recommended way to manage drawings is Worksheet#add_table

A colllection of tables associated with this workbook

Serialize the workbook

Parameters:

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

This gem no longer depends on RMagick for autowidth calculation. Thus the performance benefits of turning this off are marginal unless you are creating a very large sheet.

Indicates if the workbook should use autowidths or not.

see @use_autowidth

When true, the Package will be generated with a shared string table. This may be required by some OOXML processors that do not adhere to the ECMA specification that dictates string may be inline in the sheet. Using this option will increase the time required to serialize the document as every string in every cell must be analzed and referenced.

A collection of views for this workbook

Note:

The recommended way to manage worksheets is add_worksheet

The xml:space attribute for the worksheet. This determines how whitespace is handled withing the document. The most relevant part being whitespace in the cell text. allowed values are :preserve and :default. Axlsx uses :preserve unless you explicily set this to :default.

Sets the xml:space attribute for the worksheet

Parameters:

  • space (Symbol)

    must be one of :preserve or :default

Workbook is referenced in 0 repositories