hi all,
i've got the following program that needs yr help: -
use Win32::OLE;
-
-
# use existing instance if Excel is already running
-
eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
-
die "Excel not installed" if $@;
-
unless (defined $ex) {
-
$ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
-
or die "Oops, cannot start Excel";
-
}
-
-
-
# get a new workbook
-
$book = $ex->Workbooks->Add;
-
$sheet = $book->Worksheets(1);
-
-
# write a 2 rows by 3 columns range
-
$sheet->Range("A1:J2")->{Value} = [['Date','Total (IN)','Succ (IN)','Pk (IN)/Hrs','Pk (OUT)/Hrs','Peak Hour','Total (OUT)','Succ (OUT)','MO(IN)','MO(OUT)'],
-
[$date, $total_in, $succ_in,$pk_in,$pk_out,"$pk_hour - $pk_hour_dur hr",$total_out,$succ_out ]];
-
-
$sheet->Range("K1:L2")->{Value} = [['Pk Msg/sec','Max Pk Msg/sec'],
-
[$max_pk_msg,$pk_msg]];
-
-
-
foreach(@parameters)
-
{
-
$sheet->Cells(2,9)->{Value} = [$parameter_in_array{$_}];
-
$sheet->Cells(2,10)->{Value} = [$parameter_out_array{$_}];
-
}
-
-
# print "XyzzyPerl"
-
$array = $sheet->Range("A2:I1")->{Value};
-
for (@$array) {
-
for (@$_) {
-
print defined($_) ? "$_|" : "<undef>|";
-
}
-
print "\n";
-
}
-
-
# save and exit
-
-
$book->SaveAs ("C:\\Documents and Settings\\clong\\Desktop\\perl\\$save_file_name.xls") ;
-
undef $book;
-
undef $ex;
-
this code outputs everything to an excel sheet
however i need to append the data
how will i go about trying to determine the last row and insert it?
i considered using a counter but then i still need to determine the new cells of that the new data will go in
tough problem here, anyone pls advise?
thanks
6 6446
hm...anyone who can help? thanks alot
Sorry, I can't help. I never do anything with Excel and I have no experience with any Excel modules.
hm...thanks anyway
anyone else who might know by chance?
:)
I didn't understand your problem quite well. But if you are just checking if data exists in a given cell and appending to next cell, a counter variable and test loop should work. For ex: -
$j=1;
-
foreach(@parameters)
-
{
-
while(defined $sheet->Cells($j,9)->{Value}) { $j++;}
-
$sheet->Cells($j,9)->{Value} = [$parameter_in_array{$_}];
-
#####
-
}
-
Here, I'm using fixed column value, since you may want a particular data into particular column. You can use a variable too if required.
Not sure if I understood your requirement properly :(
Try - my $last_row = $sheet -> UsedRange -> Find({What => "*", SearchDirection => xlPrevious, SearchOrder => xlByRows}) -> {Row};
hm...basically it's like say for my 1st row my data is:
Car A SHE3442F
then when i wanna insert data of car B, i just append it like below:
Car A SHE3442F
Car B SHA2324A
hm....i try if the last row code given by windblowsME work..
another problem i see is i need to open up my saved file to add in the infomation..would it be workable still if say my first entry of data i save it in "test.xls", then at a later date if i wanna append data at "test.xls", i open the file "test.xls", does the code still works? i'm gonna try it anyway but if u got any suggestions would appreciate it!
thanks dude for the help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vinay Gupta |
last post by:
Hi,
In a Perl to Tcl conversion project, I am planning to use the
following Tcl extensions as a replacement for some Perl libraries.
My development environment is Windows.
Win32::OLE --> "DDE"...
|
by: usenet |
last post by:
Problem installing Win32::OLE under Cygwin.
I have searched the web and found little documentation on installation
procedure. Please help.
I'd like to get Win32::OLE working under cygwin.
...
|
by: yma |
last post by:
Hi,
I tried to use a listbox to display a column in MS Access 2000 nwind.mdb by
using ole DataAdapter, Connection and dataset controls. But I got "It is
already opened exclusively by another...
|
by: sandycat05 |
last post by:
Hello all, I am a new Perl programmer. Below is the beginnings of a code that I am using to manipulate an Excel spreadsheet via Perl using win32::OLE. However, what I'd like to do is the following:...
|
by: Mika M |
last post by:
Hi!
I'm trying to read text file like...
"Field1";"Field2";"Field3";"Field4"
"ABCD";"EFGH";"1234";"20051020"
"AABB";"CCDD";"2468";"20051021"
"CCDD";"XXYY";"4321";"20051022"
....using OLE...
|
by: ajaymistry |
last post by:
hi all,
I'm using OLE for accessing exel spreadsheets but i don't know how to save its data to Database and how to Retrieve saved data.
Im using SQL Server 2000 database.
If anybody have any...
|
by: PRITPAL |
last post by:
Hi There,
I want a code for Saving and Reading formatted text (RTF File) in MS Access using ole Objects, i want to save 20 such records in DB using VB 6.0. Plz Help
|
by: John Randall |
last post by:
Anybody got some sample code showing how to create a word doc and insert text plus images, such as .gif or jpg files? I'm new to Win32::OLE. Thanks in advance.
|
by: mohanprasadgutta |
last post by:
Hi,
I need help to open a password protected excel file in perl using Win32:OLE.
when I tried to open file in normal way at the time of program execution it is prompting me to enter password.
I am...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |