Export to Excel

bendiy - July 14, 2009 - 23:01
Project:Views Bonus Pack
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

This patch addresses previous issues to provide an option to Export to Excel.
This is an updated port of the patch in Issue #444412 that has been updated to work with Views Bonus -6.x-1.x-dev as of July 07 2009. This patch only addresses the Excel Export function. See also Issue #262338.

The method for this export is via HTML Table. I believe this is the best method for the following reasons:

  • Currencies - If a field value is formatted to show $10.99, Excel will see it as a Currency Field Format with value 10.99. This allows the field to be summed as a number.
  • Hyperlinks - Excel will preserve any links in Views Fields. If this link is an Views Argument link, in Excel, you can click on the link and go directly to the web page.
  • Text Formats - Bold, Italic, etc. will carry over to Excel.

All of these features make the HTML Table Excel export much more user friendly. Your users can start to use the export, email it and read it immediately. A direct data export like Views_Export _XLS does not persevere all of this info. You have to reformat all of the data in Excel before it's readable and usable.

This patch should be applied to sites/all/modules and will update the folder views_bonus inside of modules. You will need to copy the attached xls.png into the sites/all/modules/views_bonus/export/images.

AttachmentSize
views_bonus.patch4.64 KB
xls.png378 bytes

#1

neclimdul - July 16, 2009 - 07:14
Status:active» needs review

Thanks, initial look at the patch seems pretty good. Will give it a closer look as time permits.

#2

giorez - July 16, 2009 - 16:48

your patch is rejected on attached file

AttachmentSize
views-bonus-export-csv.tpl_.php.txt 516 bytes

#3

bendiy - July 18, 2009 - 05:35

This patch shouldn't even touch views-bonus-export-csv.tpl. Not sure what problem you are having.

#4

rconstantine - July 20, 2009 - 17:46

Subscribing, and question:

Will this address issues with bullets (for example)?

I'm using WYSIWYG editors all over. Users enter in bulleted lists quite often. I show these in tabular views as one column. When exporting to CSV, the bullets turn into some funky characters and of course lose formatting (carriage returns?). Ideally, exporting to XLS would solve that and keep the bullets intact.

#5

Ned Needle - August 18, 2009 - 11:36

Exporting automatically to excel without any patch is working fine for me.

Chose style as "doc file", and inside the parameters check "provide as file" and then change the proposed filename from "view-%view.doc" to "view-%view.xls"

It will then open excel instead of word, keeping the format fields.

#6

iNade - October 15, 2009 - 03:33

Any news about this project ?

Can't open any ;XLS file or whatsoever : seems that the export are not that good.

#7

andreiashu - October 16, 2009 - 16:14

Attached is an updated patch against the latest Dev snapshot.

AttachmentSize
views_bonus_xls_patch_2.patch 2.19 KB

#8

gengel - October 21, 2009 - 23:05

+1 vote for this patch or something similar

Export to CSV doesn't work in Excel if you have Unicode characters in your data. I needed to export a View to Excel and ended up going with a solution quite similar to this (before I discovered this patch existed.) For this reason, and those cited above, I think HTML-within-XLS is the best option.

#9

neclimdul - October 23, 2009 - 18:23
Status:needs review» needs work

The patch is actually missing the template so it's not very reviewable. Everything else looks fine.

#10

vivianspencer - November 27, 2009 - 11:11

Have any of you seen the following library: http://phpexcel.codeplex.com, it looks like a much better alternative to the library used in http://drupal.org/project/views_export_xls or the HTML table solution used in this patch.

Take a look at the features: http://phpexcel.codeplex.com/wikipage?title=Features&referringTitle=Home

#11

vivianspencer - December 1, 2009 - 14:41

I've created a module which allows you to use PHP Excel with views if anyone is interested.

AttachmentSize
views_phpexcel.zip 14.79 KB
 
 

Drupal is a registered trademark of Dries Buytaert.