andreas1234567 has asked for the wisdom of the Perl Monks concerning the following question:

Honored monks,

I would like to produce reports in both Excel and HTML from the same source. Excel::Template provides the basic functionality I need, where xml is used as template. This node describes sample use. HTML::Template has a different approach, where html with custom tags are used as template.

Is it possible to use the same source to create reports on both Excel and HTML?

--
Andreas

Replies are listed 'Best First'.
Re: Create Excel and HTML from same source
by wfsp (Abbot) on Mar 23, 2007 at 08:44 UTC
    From Excel::Template docs:
    This is a module used for templating Excel files. Its genesis came from the need to use the same datastructure as HTML::Template, but provide Excel files instead.
    Isn't this what you want? If not you'll have to provided a bit more detail of what you are trying to do.
      .. the same datastructure as HTML::Template, but provide Excel files instead.
      The datastructure is the same, but the markup is very different. I would like to keep both the datastructure and the markup the same for both Excel and HTML.

      I do recognize dragonchild's comment that Excel and HTML layout are indeed driven by different needs. Meanwhile I'm curious as to whether it is possible to use the same datastructure and markup for both Excel and HTML output, at least for the most simple cases.
        If you can guarantee that your output will only be opened by Microsoft Excel itself, you can provide an HTML file with a table in it and Excel will do the appropriate thing. If I'm not mistaken, it will even handle basic CSS, but I wouldn't fool around with your full HTML page. So, you'll want to create a template for the table and include it into the main HTML wrapper template for HTML output and use it with a simplified wrapper for XLS output.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: Create Excel and HTML from same source
by dragonchild (Archbishop) on Mar 23, 2007 at 13:38 UTC
    The problem I faced when writing Excel::Template was that there are different formatting and layout needs driving an Excel file vs. an HTML file. For example, where would you want to put the navbar in an Excel file?

    Now, something else that's possible is that Excel will gladly read in an HTML table and plop stuff in the right place. Maybe that's what you want. I wouldn't trust it, personally.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?