If you are simply using Excel to maintain tabular data that will eventually be processed by a CGI script, you can do yourself a big favor by exporting the data into a format that is easier for Perl to digest. Excel can export a worksheet in HTML format, which can then be read with any of the HTML parser modules or simply uploaded to the server for direct consumption by browsers; or it can export the data as a CSV (comma-separated variable) file, for which there are other modules with which Perl can massage the data.

On the other hand, if you want to use CGI to massage data already present on the server to produce a file intended for consumption by Excel, your best bet is to name the script with a .csv extension, and produce valid CSV output from the script (preferably with a module designed for the purpose). Internet Explorer will (by default) then open the CGI script in Excel, embedded in your browser window.

A naive approach to parsing CSV with split() or creating CSV with join() will often work if you are sure your data will never contain embedded commas or quotation marks. However, that is only a subset of valid CSV; hence the recommendation to use modules, which handle these cases better than split and join are capable of. HTML, on the other hand (and particularly Microsoft generated HTML) must be parsed rather than analyzed with split and join, and thus the modules are essential.

Hope this helps.


In reply to Re^3: adding modules by bigmacbear
in thread adding modules by ketaki

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.