What module(s) are you using? What application are you using to "open the Excel file"?

If you are using one of the Spreadsheet::* modules, I'd agree with what others are saying about having the file open could be locking the file from being accessed/modified by other applications, which would include your script.

If you're using Win32::OLE in your script to directly control Excel and you're opening the file with Excel, it is possible for your script to take control over your Excel instance to modify the contents of the file. However, I personally would not go with that approach. Instead, I would close the file and have your script open a new instance of Excel to open the file for manipulation. See Re: Manipulating open excel sheet for more details on why having your script grab control over an existing instance of Excel could be problematic.

Regardless of which modules you use and which app you're using to open the file, I personally believe that you'll have far less issues if you don't have the file opened in any application when you run your script.


In reply to Re: writing to an open Excel file by dasgar
in thread writing to an open Excel file by bts974

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.