Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel export? #18

Closed
ghost opened this issue Apr 29, 2010 · 7 comments
Closed

Excel export? #18

ghost opened this issue Apr 29, 2010 · 7 comments

Comments

@ghost
Copy link

ghost commented Apr 29, 2010

I would like to not only have .csv export, but proper MS-Excel export as well, maybe by using the Ruby Spreadsheet gem in connection with Wice Grid? Thank you for the great Wice Grid, it really rocks, btw!

@leikind
Copy link
Owner

leikind commented May 21, 2010

I am glad you've found WiceGrid of use to you.

I haven't been active in developing the plugin lately due to lack of free time,
but as soon as I come back to WiceGrid my priority number 1
will be adding support for jQuery.

But anyway, CSV generation is done via a very simple class
named Wice::Spreadsheet which has just methods for
(1) adding a row
(2) getting the path to the CSV spreadsheet
(3) getting the data (to_csv)

This is a dead simple class.

If you or anybody else could provide me with a class having a
similar simple interface but generating files in any other format,
I'd be glad to add it to WiceGrid.

@tomkurt
Copy link

tomkurt commented Nov 30, 2011

My hack, which is not making a special excel file but just present the csv as an excel file.
Excel will open it like an other excel file but actually it's realy a plain csv file.
Down side is no formatting, the advantage is that users can easily open up csv files without being bothered with import wizards.

  def index
    @grid = initialize_grid(
      Product,
      :enable_export_to_csv => true
    )
    if params[:grid] && params[:grid][:export] == "csv"
      response.headers['Content-Disposition'] = "attachment; filename=\"productss.xls\""
      response.headers['Content-Type'] = "application/vnd.ms-excel; charset=UTF8"
      respond_to{ |format| format.csv }
    else
      respond_to{ |format| format.html }
    end
  end

@leikind
Copy link
Owner

leikind commented Nov 30, 2011

The change you are proposing is actually replacing 'text/csv' by 'application/vnd.ms-excel' ( https://github.com/leikind/wice_grid/blob/rails3/lib/wice_grid_controller.rb#L120), right?

@tomkurt
Copy link

tomkurt commented Dec 8, 2011

Yes exactly! if this was configurable you could also let one choose.
It's dead easy and doesn't require excel specific code. Isn't that amazing?
The user will open it like it was an excel file. works in all excel versions!

@leikind
Copy link
Owner

leikind commented Dec 8, 2011

Well, CSV files are always opened by a spreadsheet program, so this is not a revelation to me. I don't use Windows, but I saw WiceGrid used by my colleagues on Windows, and somehow their Excel opens files downloaded with the 'text/csv' MIME type. Anyway, I consider 'text/csv' to be the standard, and 'application/vnd.ms-excel' is Windows specific. I wouldn't mind such an option in export_grid_if_requested (https://github.com/leikind/wice_grid/blob/rails3/lib/wice_grid_controller.rb#L110). Are you interesting in forking the plugin and adding and documenting the feature?

@tomkurt
Copy link

tomkurt commented Dec 8, 2011

Yes, I would like to fork :), If you have users who don't want to now what CSV is. Or users who don't want to be bothered with the standard import wizard that excel displays when opening CSV files over and over again. I know it's just something small but our users need it.

@leikind leikind closed this as completed May 21, 2012
@l3iodeez
Copy link

I might add a separate link for the Excel-type CSV just so my users arent confused by the import wizard.

hishammalik pushed a commit to arkhitech/wice_grid that referenced this issue Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants