This came about from the chatterbox.

Thanks go to one4k4 for the original question and tye, and ar0n for their input
This snippet is a proof that XL95 or higher will parse an HTML fragment and attempt to push it into a spreadsheet. When excel encounters a table, it'll deal with it (surprisingly) intelligently.
This trick relies on (I believe) Office 95 or higher, and a browser that understands that "Content-disposition" is important...
Please post what versions of excel you test on, if you do.
Obviously, there's a lot more you can do with this type of thing; this is merely to show that it works -- this should reduce the amount of time people spend dickering with excel::spreadsheet. Note that because of the way excel translates the HTML, you'll only get one spreadsheet per workbook, so if that's a limitation, you're back to excel::spreadsheet...
Also interesting is the formula in the third row; excel Does The Right Thing with it; I imagine this could be made to be as complex as excel allows, up to and including things like :
=SUM(foo!$AO$4,foo!$A$177:$A$219,foo!$AO$177:$AO$219,4) .

Again, please comment with experiences.

use strict; use CGI qw(:all); print header(-type=>"application/excel\nContent-disposition: attachmen +t; filename=myfile.xls") ; print "<TABLE border=1> <TBODY> <TR> <TD>1 <TD>2 <TD>3 <TR> <TD>1 <TD>2 <TD>3 <TR> <TD>1 <TD>2 <TD>3 <TR> <TD>1 <TD>2 <TD>=a1*b1*c1 <TR> <TD>1 <TD>2 <TD>3 </TR></TBODY></TABLE>"; print end_html;
update

It appears that Excel will generate (I think) it's own style sheet when exporting to html. This (among other things) determines how the spreadsheet will look to Excel, but leaves it pretty plain looking in the browser.

<head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252 +"> <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 9"> <link rel=File-List href="./trash_files/filelist.xml"> <style id="trash.html_16110_Styles"> <!--table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";} .xl1516110 {padding-top:1px; padding-right:1px; padding-left:1px; mso-ignore:padding; color:windowtext; font-size:10.0pt; font-weight:400; font-style:normal; text-decoration:none; font-family:Arial; mso-generic-font-family:auto; mso-font-charset:0; mso-number-format:General; text-align:general; vertical-align:bottom; mso-background-source:auto; mso-pattern:auto; white-space:nowrap;} --> </style> </head>

In reply to Dealing intelligently with Excel files through HTML tables. by boo_radley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.