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

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

** and **

http://github.com/straydogstudio/axlsx_rails
Axlsx_Rails provides an Axlsx renderer so you can move all your spreadsheet code from your controller into view files. Partials are supported so you can organize any code into reusable chunks (e.g. cover sheets, common styling, etc.) You can use it with acts_as_xlsx, placing the to_xlsx call in a view and add ':package => xlsx_package' to the parameter list. Now you can keep your controllers thin!

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.

Feature List

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

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.

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.

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.

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.

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

Add jpg, gif and png images to worksheets with hyperlinks

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

Cell level style overrides for default and customized style objects

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

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

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

Output to file or StringIO

Support for page margins and print options

Support for password and non password based sheet protection.

First stage interoperability support for GoogleDocs, LibreOffice,
and Numbers

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

Data labels for charts as well as series color customization.

Support for sheet headers and footers

Pivot Tables

Page Breaks

Installing

To install Axlsx, use the following command:

$ geminstallaxlsx

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.

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:

geminstallyardyardserver-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

September.12.13:2.0.1

Unpinned rubyzip version

September.12.13:2.0.0

DROPPED support for ruby 1.8.7

Altered readme to link to contributors

Lots of improvements to make charts and relations more stable.

Patched color param mutation.

Data sourced for pivot tables can now come from other sheets.

Altered image file extension comparisons to be case insensitive.

Added control character sanitization to shared strings.

Added page breaks. see examples/example.rb for an example.

Bugfix: single to dual cell anchors for images now swap properly so you can set the end_at position during instantiation, in a block or directly on the image.

Improved how we convert date/time to include the UTC offset when provided.

Pinned rubyzip to 0.9.9 for those who are not ready to go up. Please note that release 2.0.1 and on will be using the 1.n.n series of rubyzip

Added support for specifying between/notBetween formula in an array.
thanks straydogstudio!

Added standard line chart support. thanks scambra

Fixed straydogstudio's link in the README. thanks nogara!

February.4.13:1.3.5

converted vary_colors for chart data to instance variable with appropriate defulats for the various charts.

Added trust_input method on Axlsx to instruct the serializer to skip HTML escaping. This will give you a tremendous performance boost,
Please be sure that you will never have <, >, etc in your content or the XML will be invalid.

Rewrote cell serialization to improve performance

Added iso_8601 type to support text based date and time management.

Bug fix for relationahip management in drawings when you add images
and charts to the same worksheet drawing.

Added outline_level_rows and outline_level_columns to worksheet to simplify setting up outlining in the worksheet.

Added support for pivot tables

Added support for descrete border edge styles

Improved validation of sheet names

Added support for formula value caching so that iOS and OSX preview can show the proper values. See Cell.add_row and the formula_values option.