SPUG: Newbie problem with Win32::OLE

Johnston, Mark mark.johnston at pnl.gov
Tue Dec 5 12:17:24 CST 2000

I don't know if this might help, but MS Excel can read a file in HTML format and
save it in .XLS format.  If you create an HTML page with the data contained in a
<table>, then give the page a MIME type which the client machine can associate
with MS Excel (Microsoft automagically installs the type
"application/vnd.ms-excel" for Office 97), then that's all you have to do -- and
it bypasses the complication of what the proper CSV format ought to be.


	Mark Johnston
	Pacific Northwest National Laboratory
	mailto:mark.johnston at pnl.gov

	-----Original Message-----
	From:	Adam Monsen [SMTP:meonkeys at hotmail.com]
	Sent:	Monday, December 04, 2000 5:57 PM
	To:	traciee at wrq.com; spug-list at pm.org
	Subject:	Re: SPUG: Newbie problem with Win32::OLE

	>In a nutshell, I am importing some text files from Unix, "converting"
	>to .csv files. I then open the .csv files in Excel and "save as" Excel 
	>(.xls). The whole thing works great, except that when I open the 
	>.xls files, the data is no longer columnar (it is a single line
	I would recommend Text::CSV_XS for parsing/generating files in csv
	Try something like this (# added before each Perl line for clarity):

	# #!/usr/bin/perl -w
	# use strict;
	# use Text::CSV_XS;
	# my $csv = Text::CSV_XS->new( {always_quote=>1} );
	# my @arr = qw(one two three);
	# $csv->combine(@arr);
	# $line = $csv->string;
	# print $line,"\r\n";

	Setting always_quote to 1 ensures that every field is quoted, which
	allow all your Win32 apps to read the csv file.

	Your problem may be later on when you save the file in Excel. I have
	around with this somewhat, and it appears that different Win32 apps use 
	different formats for csv files. For instance, after I saved a file in
	format in Excel 98, it could not be imported as csv by Access 2000.

	On a side note, I would be interested if you have read and could point
me to 
	a spec for csv.

	Did that help?

	Adam Monsen

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list