2

I'm developing a module. I need to give to the users the option to download the coupons in XLS (Excel) format.

How I can do this?

1
  • 1
    It depends on a lot of things NOT mentioned in this question. Coupons for what? Commerce? Ubercart? General Coupons? Are you just looking to run a DB query and then export the results to an XLS sheet? As it stands it's impossible to answer this question, I'd suggest editing it with more information.
    – Chapabu
    Commented May 13, 2012 at 14:58

2 Answers 2

0

I'm assuming you are using some content type for the content needed on your module. If so, then you can use Views with a module like Views Data Export.

1
  • 1
    I would HATE to have to have Views as a dependency of my module unless it was a Views plugin of some sort.
    – Chapabu
    Commented May 13, 2012 at 15:14
0

As an alternative to the Views Data Export module (suggested in another answer here), you could also use the Forena module to create an appropriate report, and then save (export) the report data (= query results) in the desired format, of which XLS is one of the supported options (apart from CSV, HTML, DOC, PDF, etc). For an online example of this, refer to the Customized Simple Table of States, and its related annotations to explain the example.

For somebody who rather wants/needs a JSON or XML format, refer to my answer to "How to add a link to the CSV download to my module page, for a report created with Forena?".

To integrate Forena in a custom module, use any of the hooks available to do so, as documented in Forena's Developers Guide.

Not the answer you're looking for? Browse other questions tagged or ask your own question.