What I have tried and found not to work:
$generalSheet->Range("A2")->Select;
ActiveWindow->{FreezePanes} = True;
> I'm trying to freeze panes in excel without using a module,
Can you show how you deal with Excel documents without using any module?
Sinan
--
A. Sinan Unur <1u...@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
use Win32::OLE::Const 'Microsoft Excel';
$Excel = Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{Visible} = 1;
$Book = $Excel->Workbooks->Add;
$generalSheet = $Book->Worksheets(1);
$generalSheet->Cells(1, 3)->{Value} = 'Data';
$LastRow =
($generalSheet->Cells->SpecialCells(xlCellTypeLastCell)->{Row});
foreach $value (@valueArray)
{
$generalSheet->Cells($LastRow, 3)->{Value} = $value;
}
$generalSheet->Columns->AutoFit;
$Book->Save;
$Book->Close;
$Excel->Quit;
Hold it. Spreadsheet::WriteExcel _is_ a module.
How can you ask for a solution that does not use a module when
you are already using a module?
-Joe
[ When compsing a follow-up, please make sure to quote context. ]
> "A. Sinan Unur" <1u...@llenroc.ude.invalid> wrote in
news:Xns97009C0EBFCC...@127.0.0.1:
>
>> mrblu...@yahoo.com wrote in news:1130787698.326521.209170
>> @g44g2000cwa.googlegroups.com:
>>
>>> I'm trying to freeze panes in excel without using a module,
>>
>> Can you show how you deal with Excel documents without using any
>> module?
>
> This is a short example of how I do it
>
> use Win32::OLE::Const 'Microsoft Excel';
You are using modules.
I don't think you are using them correctly.
The code you posted is missing:
use strict;
use warnings;
use Win32::OLE;
$Win32::OLE::Warn = 3;
> $Excel = Win32::OLE->new('Excel.Application', 'Quit');
See the Win32::OLE documentation for a way of doing this correctly.
> foreach $value (@valueArray)
There is no other mention of @valueArray in your code.
You'll need to post sample code that can be compiled and run.
use Win32::OLE::Const 'Microsoft Excel';
use strict;
use warnings;
$Win32::OLE::Warn = 3;
my $Excel = Win32::OLE->new('Excel.Application', 'Quit');
$Excel->{Visible} = 1;
my $Book = $Excel->Workbooks->Add;
my $generalSheet = $Book->Worksheets(1);
$generalSheet->Cells(1, 3)->{Value} = 'Data';
my $LastRow =
($generalSheet->Cells->SpecialCells(xlCellTypeLastCell)->{Row});
my @valueArray = ();
push(@valueArray,"Value1");
push(@valueArray,"Value2");
push(@valueArray,"Value3");
push(@valueArray,"Value4");
foreach my $value (@valueArray)
{
$LastRow++;
$generalSheet->Cells($LastRow, 3)->{Value} = $value;
}
$generalSheet->Columns->AutoFit;
$Book->Close;
$Excel->Quit;
[ Please quote an appropriate amount of context when you reply. ]
> I don't actually need to strict and get warnings
You may think so. However, originally, you posted:
> $generalSheet->Range("A2")->Select;
> ActiveWindow->{FreezePanes} = True;
Here is what perl has to say about these lines with strictures and
warnings enabled:
D:\Home\asu1\UseNet\clpmisc> bug
Can't use bareword ("ActiveWindow") as a HASH ref while "strict refs" in
use at D:\Home\asu1\UseNet\clpmisc\bug.pl line 38.
D:\Home\asu1\UseNet\clpmisc> bug
Bareword "True" not allowed while "strict subs" in use at D:\Home\asu1
\UseNet\clpmisc\bug.pl line 38.
Execution of D:\Home\asu1\UseNet\clpmisc\bug.pl aborted due to
compilation errors.
#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;
my $Excel;
eval {
$Excel = Win32::OLE->GetActiveObject('Excel.Application')
};
die "Excel not installed" if $@;
unless (defined $Excel) {
$Excel = Win32::OLE->new('Excel.Application', sub { $_[0]->Quit })
or die "Cannot start Excel";
}
$Excel->{Visible} = 1;
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
$Sheet->Cells(1, 3)->{Value} = 'Data';
my $LastRow = $Sheet->Cells->SpecialCells(xlCellTypeLastCell)->{Row};
my @valueArray = qw( value1 value2 value3 value4 );
for my $value (@valueArray) {
$LastRow++;
$Sheet->Cells($LastRow, 3)->{Value} = $value;
}
$Sheet->Columns->AutoFit;
$Sheet->Range("A2")->Select;
$Excel->ActiveWindow->{FreezePanes} = 1;