I'm using Win32::OLE to open and read spreadsheets. This works fine for a spreadsheet created with Excel, but when I try to use it to open a spreadsheet that I generated using Spreadsheed::WriteExcel, I get this error message:

OLE exception from "Microsoft Office Excel": './test.xls' could not be found. Check the spelling of the file name, +and verify that the file location is correct. If you are trying to open the file from your list of most recently use +d files, make sure that the file has not been renamed, moved, or deleted +. Win32::OLE(0.1709) error 0x800a03ec in METHOD/PROPERTYGET "Open" at C:/workspace/graph.pl line 12

but, the file is there and does exist, in that directory. The code for opening the Excel sheet is:

use strict; use warnings; use 5.010; #use Spreadsheet::WriteExcel; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn=3; my $Excel=Win32::OLE->GetActiveObject('Excel.Application')|| Win32::OLE->new('Excel.Application', 'Quit'); my $book=$Excel->Workbooks->Open("./test.xls"); my $sheet=$book->Worksheets(1);
The code I'm using to create the spreadsheets is (I'm just posting the relevant parts):
use strict; use warnings; use 5.010; use Spreadsheet::WriteExcel; $filename="".$currSite.".xls"; $workbook = Spreadsheet::WriteExcel->new($filename); $worksheet = $workbook->add_worksheet(); while(<$file>){ $worksheet->write($row,0,$year); $worksheet->write($row,1,$count); $row++; } $workbook->close();
I don't know what is wrong. Perhaps there are some permissions that are wrong? Thanks for any help and/or nudges in the right direction.

In reply to Problem opening WriteExcel generated spreadsheets with OLE by vassago

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.