When - as suggested - you produce correct (and valid) CSV *), there are utilities available that can convert CSV to XLS or HTML.

e.g. Spreadsheet::Read comes with xlscat that offers the -H option.

$ cat test.csv header,line,1 a,34,12 b,42, c, ,mars $ xlscat -H test.csv >test.html 3 x 4 $

The HTML includes a valid header with CSS, so you can alter the output appearance (with alternating even/odd line coloring)

<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/T +R/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>test.csv</title> <meta name="Author" content="xlscat 2.1" /> <style type="text/css"><!-- body, h2, td, th { font-family: "Nimbus Sans L", "DejaVu Sans", Helvetica, Arial, sans; } table { border-spacing: 2px; border-collapse: collapse; } td, th { vertical-align: top; padding: 4px; } table > tbody > tr > th, table > tr > th { background: #e0e0e0; } table > tbody > tr > td:not([class]), table > tr > td:not([class]) { background: #f0f0f0; } .odd { background: #e0e0e0; } --></style> </head>

test.csv

headerline1
a3412
b42
cmars

*) Producing valid CSV with Text::CSV_XS or Text::CSV is easy, use print as demonstrated in this example.


Enjoy, Have FUN! H.Merijn
titletd

In reply to Re: CSV or HTML? by Tux
in thread CSV or HTML? by jms53

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.