harvesthq/axlsx

Name: axlsx

Owner: Harvest

Description: xlsx generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.

Forked from: randym/axlsx

Created: 2017-08-30 16:03:49.0

Updated: 2017-10-11 03:35:08.0

Pushed: 2017-08-04 17:25:01.0

Homepage:

Size: 9785

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Axlsx: Office Open XML Spreadsheet Generation

Build Status

If you are using axlsx for commercial purposes, or just want to show your appreciation for the gem, please don't hesitate to make a donation.

Click here to lend your support to: axlsx and make a donation at www.pledgie.com !

IRC:irc.freenode.net / #axlsx

Git:http://github.com/randym/axlsx

Twitter: https://twitter.com/morgan_randy

Google Group: https://groups.google.com/forum/?fromgroups#!forum/axlsx

Author: Randy Morgan

Copyright: 2011 - 2013

License: MIT License

Latest Version: 2.0.1

Ruby Version: 1.9.2, 1.9.3, 2.0.0

JRuby Version: 1.9 modes

Rubinius Version: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.

Release Date: September 12th 2013

If you are working in rails, or with active record see: acts_as_xlsx

acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:

s.where(created_at > Time.now-30.days).to_xlsx

and

There are guides for using axlsx and acts_as_xlsx here: http://axlsx.blog.randym.net

If you are working with ActiveAdmin see:

activeadmin-axlsx

It provides a plugin and dsl for generating downloadable reports.

The examples directory contains a number of more specific examples as well.

Synopsis

Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language. With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, tables, conditional formatting, print options, comments, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification.

Screen 1

Feature List
  1. Author xlsx documents: Axlsx is made to let you easily and quickly generate professional xlsx based reports that can be validated before serialization.

  2. Generate 3D Pie, Line, Scatter and Bar Charts: With Axlsx chart generation and management is as easy as a few lines of code. You can build charts based off data in your worksheet or generate charts without any data in your sheet at all. Customize gridlines, label rotation and series colors as well.

  3. Custom Styles: With guaranteed document validity, you can style borders, alignment, fills, fonts, and number formats in a single line of code. Those styles can be applied to an entire row, or a single cell anywhere in your workbook.

  4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String, Date, Time and Boolean types are automatically identified and serialized to your spreadsheet.

  5. Automatic and fixed column widths: Axlsx will automatically determine the appropriate width for your columns based on the content in the worksheet, or use any value you specify for the really funky stuff.

  6. Support for automatically formatted 1904 and 1900 epochs configurable in the workbook.

  7. Add jpg, gif and png images to worksheets with hyperlinks

  8. Reference cells in your worksheet with “A1” and “A1:D4” style references or from the workbook using “Sheet1!A3:B4” style references

  9. Cell level style overrides for default and customized style objects

  10. Support for formulas, merging, row and column outlining as well as cell level input data validation.

  11. Auto filtering tables with worksheet.auto_filter as well as support for Tables

  12. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).

  13. Output to file or StringIO

  14. Support for page margins and print options

  15. Support for password and non password based sheet protection.

  16. First stage interoperability support for GoogleDocs, LibreOffice, and Numbers

  17. Support for defined names, which gives you repeated header rows for printing.

  18. Data labels for charts as well as series color customization.

  19. Support for sheet headers and footers

  20. Pivot Tables

  21. Page Breaks

Installing

To install Axlsx, use the following command:

$ gem install axlsx

Examples


The example listing is getting overly large to maintain here. If you are using Yard, you will be able to see the examples in line below.

Here's a teaser that kicks about 2% of what the gem can do.

x::Package.new do |p|
workbook.add_worksheet(:name => "Pie Chart") do |sheet|
sheet.add_row ["Simple Pie Chart"]
%w(first second third).each { |label| sheet.add_row [label, rand(24)+1] }
sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,5], :end_at => [10, 20], :title => "example 3: Pie Chart") do |chart|
  chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"],  :colors => ['FF0000', '00FF00', '0000FF']
end
d
serialize('simple.xlsx')

Please see the examples for more.

{include:file:examples/example.rb}

There is much, much more you can do with this gem. If you get stuck, grab me on IRC or submit an issue to GitHub. Chances are that it has already been implemented. If it hasn't - let's take a look at adding it in.

Documentation


This gem is 100% documented with YARD, an exceptional documentation library. To see documentation for this, and all the gems installed on your system use:

 gem install yard kramdown

 yard server -g

Specs


This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.

Change log


Please see the {file:CHANGELOG.md} document for past release information.

Known interoperability issues.

As axslx implements the Office Open XML (ECMA-376 spec) much of the functionality is interoperable with other spreadsheet software. Below is a listing of some known issues.

  1. Libre Office

  2. You must specify colors for your series. see examples/chart_colors.rb for an example.

  3. You must use data in your sheet for charts. You cannot use hard coded values.

  4. Chart axis and gridlines do not render. I have a feeling this is related to themes, which axlsx does not implement at this time.

  5. Google Docs

  6. Images are known to not work with google docs

  7. border colors do not work

  8. Numbers

  9. you must set 'use_shared_strings' to true. This is most conveniently done just before rendering by calling Package.use_shared_strings = true prior to serialization.

    Axlsx::Package.new
    rkbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
    t.add_row ["First Column", "Second", "Third"]
    t.add_row [1, 2, 3]
    
    e_shared_strings = true
    rialize('simple.xlsx')
    
  10. charts do not render

Thanks!

Open source software is a community effort. None of this could have been done without the help of these awesome folks.

contributors

Copyright and License


Axlsx © 2011-2013 by Randy Morgan.

Axlsx is licensed under the MIT license. Please see the LICENSE document for more information.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.