Hi
Folks,
I'm having trouble
formatting the Cell Contents of an Excel sheet with
Win32::OLE.
I want to force the
contents of a Cell that has a DATE value ( "Dec 2005" ) to be a
string.
What happens is the
Date value 'DEC 2005' in converted into 'Dec-05'.
Any help will be
greatly appreciated....
Thanks,
Glen Plantz
Glen Plantz
Here is my
code;.
---------------------------------------------------------------------------------------------------------------------------------------------------
my ($currentMonth,
$currentYear ) = split / /,
$currentMonthYear;
# holds "Dec 2005"
# Now open the
TEMPLATE FILE where this month value will be used...
# $CSAA_A2_RegionOffice
my $template_Workbook = $excel_app->Workbooks->Open($CSAA_A2_RegionOffice)
or die "could not open $CSAA_A2_RegionOffice\n";
# $CSAA_A2_RegionOffice
my $template_Workbook = $excel_app->Workbooks->Open($CSAA_A2_RegionOffice)
or die "could not open $CSAA_A2_RegionOffice\n";
#now select first
column heading where HOA will be used... and try putting the correct column
heading in...
my $Sheet1 = $template_Workbook->Worksheets(1);
$Sheet1->Range("D2")->Select();
my $Sheet1 = $template_Workbook->Worksheets(1);
$Sheet1->Range("D2")->Select();
#now select correct array based on the '$currentMonth' value
my $mnth;
my $i = 0;
my $mnth =
$HOA{$currentMonth}[$i]; # $mnth holds 'DEC'
#correct value...
now try putting in the correct value...
my $monthYear =
$mnth . ' ' . $currentYear;
print "monthYear =
$monthYear\n";
# my $dt =
Variant(VT_DATE, $monthYear);
print
"$dt\n";
print $dt->Date("MMM yyyy"), "\n";
print $dt->Date("MMM yyyy"), "\n";
my $formatedDate =
$dt->Date("MMM yyyy"), "\n";
print "formatedDate = $formatedDate\n";
print "formatedDate = $formatedDate\n";
# this works, but
the year has the format '05'.... see screen
shot...
$Sheet1->Range("D2")->{'Value'} = $monthYear;
$Sheet1->Range("D2")->{'Value'} = $monthYear;
# this does not
work
#$Sheet1->Range("D2")->{'Value'} = $formatedDate;
#$Sheet1->Range("D2")->{'Value'} = $formatedDate;
#this doesn't seem
to effect the value entered...
#$Sheet1->Range("D2")->Format("MMM yyyy");
#$Sheet1->Range("D2")->Format("MMM yyyy");
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
