You're code is correct, in that you are attempting to copy a binary spreadsheet file directly to the port of a printer. As you discovered, this is not the way to actually have any readable output. What you have to do is to use the print functionality of a spreadsheet application to send formatted printer control language data to the file. That is, you are trying to use Perl to do the equivalent of File->Open, File->Print. There are a couple of ways to approach that:

  1. If you're using Windows, you can use Win32::OLE to control a program such as Excel and send the print command. A good overall example can be found at tek-tips, and right here at Perlmonks Using Win32::OLE and Excel - Tips and Tricks. You'll want to set the Excel visibility to 0 (so you don't see the application when you are running it) and you want to use the PrintOut method of the active sheet to actually print the file
  2. If you're using OpenOffice.org, it has its own programming interface that you can use to open the file and print it.
  3. If you want just the raw data, you could use Spreadsheet::ParseExcel (if you're using an Excel file) to get the cell contents programatically and then use the Perl system command to invoke lpr on the resulting formatted text.

Because of the operating system specific nature of printing (whether Windows, Mac, or *NIX), you need to tell us:

if you want truly detailed and good answers


In reply to Re: Printing spreadsheets by Sinistral
in thread Printing spreadsheets by merrymonk

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.