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 inherited from Writexlsx::Workbook

Writexlsx::Workbook::EMPTY_HASH

Constants included from Writexlsx::Utility

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

Instance Attribute Summary

Attributes inherited from Writexlsx::Workbook

#activesheet, #charts, #custom_properties, #default_url_format, #doc_properties, #drawings, #embedded_descriptions, #embedded_image_indexes, #embedded_images, #excel2003_style, #firstsheet, #image_types, #images, #max_url_length, #named_ranges, #palette, #read_only, #shared_strings, #strings_to_urls, #vba_project, #worksheets, #writer

Method Summary

Methods inherited from Writexlsx::Workbook

#add_chart, #add_format, #add_shape, #add_vba_project, #add_worksheet, #assemble_xml_file, #chartsheet_count, #chartsheets, #close, #date_1904?, #define_name, #get_1904, #has_dynamic_functions?, #has_embedded_descriptions?, #has_embedded_images?, #has_metadata?, #initialize, #non_chartsheet_count, #non_chartsheets, #num_comment_files, #num_vml_files, #read_only_recommended, #set_1904, #set_calc_mode, #set_custom_color, #set_custom_property, #set_properties, #set_size, #set_tab_ratio, #set_tempdir, #set_vba_name, #set_xml_writer, #shared_string_index, #shared_strings_empty?, #sheets, #str_unique, #style_properties, #worksheet_by_name, #xml_str

Methods included from Writexlsx::Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #color, #convert_date_time, #convert_font_args, #dash_types, delete_files, #escape_url, #fill_properties, #float_to_str, #get_font_latin_attributes, #get_font_style_attributes, #get_image_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color, #params_to_font, #pattern_properties, #pixels_to_points, #process_bmp, #process_gif, #process_jpg, #process_png, #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_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_a_solid_fill, #write_a_srgb_clr, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_def_rpr_r_pr_common, #write_div, #write_fill, #write_font, #write_stroke, #write_tx_pr, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xl_string_pixel_width, #xml_str

Constructor Details

This class inherits a constructor from Writexlsx::Workbook