Thanks (and ++)! Just a few minor nits...

Does everything in the output xls file really have to be bold?

Given that you start out like this:

my $infile = shift; usage() unless defined $infile && -f $infile;
your usage synopsis really should be like this:
sub usage { print "csv2xls infile [outfile] [subject]\n"; exit; }
(i.e. no brackets around "infile", because it is a required arg)

When I saw this:

# We store the string width as data in the Worksheet object. We us +e # a double underscore key name to avoid conflicts with future name +s. # my $old_width = $worksheet->{__col_widths}->[$col];
I was reminded of having to face a similar issue with DBI; in that module, the handy convention is that any time you want to add some "novel" attributes (hash keys) to the "normal" module object, you simply prefix the attribute name with "private_" -- I don't remember all the circumstances that made this "the right way to do it" with DBI, but it seems like a nice convention to use in general.

BTW, doesn't Excel already support a simple means for importing data from a csv file? I can appreciate the notion of having column widths adjusted for me automatically as the data are loaded, but in most cases, adjusting the column width in Excel isn't that much harder. I also understand the issues with really long csv data sets and the need to split them up somehow to be digestible by Excel, but in those cases, I'd have to wonder: why use Excel at all for that kind of data?

As for the last chunk of your code:

# Very simple conversion between string length and string width for Ar +ial 10. # See below for a more sophisticated method. # sub string_width { return length $_[0]; }
Is that supposed to be a joke, or did you actually leave something off at the end when you posted this? (just curious)

In reply to Re: CSV to Excel Converter by graff
in thread CSV to Excel Converter by eric256

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.