View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default minor but irritating problem when generating Excel files with Perl

Eric,
You can write the BIFF8 format to create a true Excel file.
As long as you do not want too much fancy stuff, look at
http://www.Planet-Source-Code.com/vb...11898&lngWId=1

NickHK


"Peter" <peterguy -at- hotmail -dot- com wrote in message
...
Generating text files and renaming them with a .xls extension does not

mean
that Excel will treat them as "true" Excel files. It's analogous to
renaming a text file with a .mp3 extension and expecting an mp3 player to
play it.

If you want to generate true Excel files with PERL, you'll have to do it
with OLE, as hinted at in his/her post.

-Peter


"EJF" wrote in message
...

I generate the files just like I generate any other file using Perl
except that I use the .xls extension. For example, here I do exactly
the same thing with two files, except one of them (.txt - which I never
open in Excel) behaves well and the other one (.xls, which I *do*, of
course, open in Excel) behaves poorly:

open (OUTPUT1, "test.xls");
open (OUTPUT2, "test.txt");

print OUTPUT1 "hello";
print OUTPUT2 "hello";

close OUTPUT1;
close OUTPUT2;

I run this program and I then see two files that it's generated - an
Excel file and a file in a simple text editor. If I double click on the
simple text file, it opens in a simple editor (TextEdit, as it happens -
I'm a Mac user). I can then make changes and save it and everything is
normal - it recognizes that the file that I double clicked is the same
one that I'm working in. However, if I double click on the Excel file
and make changes, then when I go to save it

a) it doesn't recognize that the file that already exists in this
folder is exactly the same file as I'm working with - otherwise it
would never say "a file with this name already exists - do you want to
replace it with the current file?"; and
b) it seems to think that my default choice to save the file would be
as a .txt file, even though the file itself is an Excel Worksheet file.


It sounds like a trivial little thing, and it is basically trivial
except that sometimes I'll generate 100 Excel files and then with each
one of them I have to go through the same silly thing.

Thanks for the help.

Eric


--
EJF
------------------------------------------------------------------------
EJF's Profile:

http://www.excelforum.com/member.php...o&userid=32065
View this thread:

http://www.excelforum.com/showthread...hreadid=518842