Git Product home page Git Product logo

active_scaffold_export's Introduction

Active Scaffold Export

An active scaffold addon to let it export data in CSV or XLSX format

####How to? Easy. First get active scaffold if you haven't yet. Then, add this to your Gemfile:

gem 'active_scaffold_export'

if you're using REE or Ruby 1.8.7, you need to add backports gem as well as fastercsv since REE lacks ruby 1.9 streaming features and fastercsv is in core in 1.9

gem 'backports'
gem 'fastercsv'

if you want xlsx format, add:

gem 'axlsx_rails'

if that gem is present, XLSX will be used by default. You can change this by adding to active scaffold config:

conf.export.default_file_format = 'csv' # or 'xlsx' 

read important notes at the bottom about xlsx.

Remember to bundle install. Add to application.css:

 *= require active_scaffold_export

Now let's add it to controller, inside active_scaffold config block:

conf.actions.add :export
# you can filter or sort columns if you want
conf.export.columns = %w(name last_name phone address) 
# you can define a default values for the exporting form
conf.export.default_deselected_columns = %w(phone address)
conf.export.default_delimiter = ";"
conf.export.force_quotes = "true"

And enjoy happy exporting :)

Security

It's controlled the same way as Active Scaffold. The extra actions added are:

  • :show_export for the options form
  • :export for retrieving the data Tested with AS internal security and Cancan

Translations

Go in the same active scaffold scope:

active_scaffold:
    columns_for_export: Columnas para exportar
    export_options: Opciones de exportación
    this_page: esta página
    all_pages: todas las páginas 

XLSX support

This support depends on axlsx_rails and axlsx of course. header styling override will be added soon. NOTE: There's NO streaming support for xlsx format. Only CSV. So if your data is huge, set default_file_format to 'csv' instead. Streaming in xlsx will never be supported since the entire file needs to be serialized and zipped to be a valid OOXML file. So, rather than streaming, background jobs will be the most likely future approach.
Read axlsx issue about this

This gem has not been tested in other rubies than REE and Ruby 1.9. For contact, help, support, comments, please use Active Scaffold official mailing list [email protected]

active_scaffold_export's People

Contributors

vhochstein avatar naaano avatar courtland avatar ewildgoose avatar deinspanjer avatar msjonker avatar ananelson avatar beatjoerg avatar lightningdb avatar scambra avatar cch4github avatar diedthreetimes avatar

Watchers

James Cloos avatar

Forkers

dlepage

active_scaffold_export's Issues

Active Scaffold Export - Difference from older Rails app

When testing the Par Level Rule Importer for a recent PR, I noticed that the export differed from the current Temperature/ Hand Hygiene Exporter. I assume this was the old importer for Activate as well.
https://github.com/cetani/Temperature/blob/bda6094b3d0a87d62f956a503ebfa039a99dcb35/vendor/plugins/ewildgoose-active_scaffold_export-0cc43ac/lib/active_scaffold/helpers/export_helpers.rb#L12-L31
https://github.com/cetani/active_scaffold_export/blob/a7845e7ce8718c7ee25813c9f3d5bb4811789eca/lib/active_scaffold/helpers/export_helpers.rb#L12-L28

The main difference here is that the old version was using the list's helper as a fallback if the export helper wasn't defined.

I think we should at least have that be a configurable option prior to upgrading Temp or HH to a later version of rails.

The case where I was this was in the Par Level Rules where the Area export was expected to show "[Entire Map]" but "-" was exported. The importer currently expects to see the "[Entire Map" not a blank entry like "-". Thus an export/import will fail. We can fix this in Activate for this case.

I just think we should add this functionality back, or add a setting to do reuse the list helper.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.