This approach provides an XML template that can be natively imported with Excel.

For a client I needed to export data from views into XML and then opening the XML file with Excel. Views bonus' default template for exporting XML is good and can be used for this purpose (this even gives you some nice formatting in Excel). However, as soon as the client wanted some special formatting in the excel file, the template was not sufficient.

The attached Excel XML template allows you to do the following

  • import a view's data natively into excel without worries
  • calculations: in the spreadsheet footer, sums are calculated for colums that contain numbers (modify for your own calculations)
  • formatting: each row has a different color than the previous one (zebra stripes)
  • formatting: some number columns use the euro currency
  • formatting: float numbers are formatted as percentage (e.g. 3.4% - modify for your own style)

How to install:

  • install the module views_bonus
  • create a view with a feed display
  • set the feed's style to XML
  • copy this template to your theme folder (anyone knows how to have it in a module?)
  • open the view and export your XML, open with excel

The template is roughly configurable within the template code.

  • change the zebra stripe colours
  • change the type mapping (view column data type to excel data type)

Helpful in writing this template were Introduction to Excel XML by Brian Jones (Part 1 and Part 2) and MSDN Documentation of Excel XML.

(Sorry, this is tested only in D6 / views export 1.1)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

organicwire’s picture

Issue summary: View changes

fixed html

neclimdul’s picture

Status: Active » Closed (outdated)