Class: WriteXLSX

Inherits:
Writexlsx::Workbook show all
Defined in:
lib/write_xlsx.rb

Overview

write is gem to create a new file in the Excel 2007+ XLSX format, and you can use the same interface as writeexcel gem. write_xlsx is converted from Perl’s module github.com/jmcnamara/excel-writer-xlsx .

Description

The WriteXLSX supports the following features:

Multiple worksheets
Strings and numbers
Unicode text
Rich string formats
Formulas (including array formats)
cell formatting
Embedded images
Charts
Autofilters
Data validation
Conditional formatting
Tables
Hyperlinks
Defined names
Grouping/Outlines
Cell comments
Panes
Page set-up and printing options

WriteXLSX uses the same interface as WriteExcel gem.

Synopsis

To write a string, a formatted string, a number and a formula to the first worksheet in an Excel XMLX spreadsheet called ruby.xlsx:

require 'write_xlsx'

# Create a new Excel workbook
workbook = WriteXLSX.new('ruby.xlsx')

# Add a worksheet
worksheet = workbook.add_worksheet

#  Add and define a format
format = workbook.add_format # Add a format
format.set_bold
format.set_color('red')
format.set_align('center')

# Write a formatted and unformatted string, row and column notation.
col = row = 0
worksheet.write(row, col, "Hi Excel!", format)
worksheet.write(1,   col, "Hi Excel!")

# Write a number and a formula using A1 notation
worksheet.write('A3', 1.2345)
worksheet.write('A4', '=SIN(PI()/4)')

workbook.close

Description

The WriteXLSX gem can be used to create an Excel file in the 2007+ XLSX format.

The XLSX format is the Office Open XML(OOXML) format used by Excel 2007 and later.

Multiple worksheets can be added to a workbook and formatting can be applied to cells. Text, numbers and formulas can be written to the cells.

This module cannot, as yet, be used to write to an exsisting Excel XLSX file.

WriteXLSX and WriteExcel

WriteXLSX uses the same interface as the WriteExcel gem which produces an Excel file in binary XLS format.

WriteXLSX supports all the features of WriteExcel and in some cases has more functionally.

Other Methods

see Writexlsx::Workbook, Writexlsx::Worksheet, Writexlsx::Chart etc.

Constant Summary

Constants included from Writexlsx::Utility

Writexlsx::Utility::COL_MAX, Writexlsx::Utility::ROW_MAX, Writexlsx::Utility::SHEETNAME_MAX, Writexlsx::Utility::STR_MAX

Instance Attribute Summary

Attributes inherited from Writexlsx::Workbook

#charts, #doc_properties, #drawings, #excel2003_style, #image_types, #images, #named_ranges, #palette, #shared_strings, #vba_project, #worksheets

Method Summary

Methods inherited from Writexlsx::Workbook

#activesheet=, #add_chart, #add_format, #add_shape, #add_vba_project, #add_worksheet, #assemble_xml_file, #chartsheet_count, #chartsheets, #close, #date_1904?, #define_name, #get_1904, #initialize, #non_chartsheet_count, #non_chartsheets, #num_comment_files, #num_vml_files, #set_1904, #set_calc_mode, #set_custom_color, #set_properties, #set_tempdir, #set_vba_name, #set_xml_writer, #shared_string_index, #shared_strings_empty?, #sheets, #str_unique, #style_properties, #writer, #xml_str

Methods included from Writexlsx::Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #dash_types, delete_files, #fill_properties, #float_to_str, #layout_properties, #line_fill_properties, #line_properties, #palette_color, #pixels_to_points, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Constructor Details

This class inherits a constructor from Writexlsx::Workbook