hi,
I am very new to perl.I have written a perl script which is writing data into an excel file.The problem is that it is creating one new excel file while executing but my need id to write into an existing .xls file.
currently I am using:
my $workbook = Spreadsheet::Wr iteExcel::Big->new("file.xls" );
for that which method Should I use??
can anyone please help me...
Thanks
Rasmia
5 11065
Have you tried using Spreadsheet::Pa rseExcel to read out the data, and then use WriteExcel to put it all back into another new file?
It's a bit of a drag, but the only other way I know how to do it is to use Win32::OLE which is (IMHO) much more awkward.
Andy
Thank You Andy..Due to our internal system problem I hav not tried Spreadsheet::Pa rseExcel .I am writing the perl script which will run on the Solaries environment.Wil l Win32::OLE work there???
My code is... -
use strict;
-
use File::Copy;
-
use File::Path;
-
use File::Basename;
-
use Spreadsheet::WriteExcel::Big;
-
use Data::Dumper;
-
-
my $wrksheet = "Details";
-
my $sheet_name;
-
my $excel_look;
-
my $v_name = "Shilpy";
-
my $v_empid= 194050;
-
#my $sFile = "test1.xls";
-
my $workbook = Spreadsheet::WriteExcel::Big->new("file.xls");
-
my $worksheet = $workbook->add_worksheet("Details");
-
-
#$sheet_name = $excel_sheet->addworksheet($wrksheet);
-
$excel_look = $workbook->addformat();
-
$excel_look->set_size(10);
-
$excel_look->set_color('black');
-
$excel_look->set_align('center');
-
$excel_look->set_font('Arial');
-
-
$worksheet->activate();
-
$worksheet->write(0,0,"Name",$excel_look);
-
$worksheet->write(0,1,"Emp Id",$excel_look);
-
Please suggest me what needs to change...
Thanks a lot
Rasmita
Hi,
Thanks Miller.I hav gone through the given links,but not get any satisfactory result.My query is when ever I will execute the script it will create the new file and erase the previous data,this is not my requirement.I want to append new data,when I will execute the script 2nd time.
Please help me, its very very urgent...
Thanks
Rasmita
Hi Rasmita,
I recently did something quite similar. The script adds tabs to an existing excel file each time it is run and saves the file. I did it using Win32::OLE. You could do something like the below: -
$filepath = 'file.xls';
-
if (-e $filepath) {
-
$Book = $Excel->Workbooks->Open($filepath);
-
$Exists = "true";
-
} else {
-
$Book = $Excel->Workbooks->Add();
-
$Exists = "false";
-
}
-
-
if ($Exists eq "true") {
-
$previousSheet = $Book->ActiveSheet;
-
$currentSheet = $Book->Worksheets->Add();
-
$Book->ActiveSheet->{Name} = "new tab";
-
} else {
-
$previousSheet = 0;
-
}
-
-
# ******** add your code here ************
-
-
if ($Exists eq "true") {
-
$Bookook->Save();
-
} else{
-
$Book->SaveAs("$filepath") or die $!;
-
}
-
Hope this helps.
KARTHIK
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dorthe Luebbert |
last post by:
Hi,
there is a new(er) version of John McNammara's Excel package for Perl:
http://homepage.eircom.net/~jmcnamara/perl/prerel/Spreadsheet-WriteExcel-0.49.7.tar.gz
The package writes Excel97 instead of Excel5, it has e.g. no longer
the 255 char's limit for one cell etc.
See:
|
by: Fabio |
last post by:
Hello,
there's a module called Spreadsheet::WriteExcel. It allows me to create
a new worksheet and edit its cells:
my $workbook = Spreadsheet::WriteExcel->new('my.xls');
my $worksheet = $workbook->addworksheet();
$worksheet -> write('A2', 222);
But how can I put some values into the cells of an existing worksheet?
|
by: tito |
last post by:
I am using Active Perl for running perl programs.I am finding difficulty in installing Spreadsheet::WriteExcel,Spreadsheet:ParseExcel to the machine for writing a program which will retrieve data from an Excel Sheet.
Can anyone explain me the steps to install Spreadsheet::WriteExcel,Spreadsheet:ParseExcel in Windows machine.
|
by: toffee |
last post by:
Hi all,
I got a pre-formatted spreadsheet. would it be possible using js to copy the
data from a table on the current webpage, open the spreadsheet and paste the
content ?
if so, anyone got any links or pointers?
i've already tried google - but all i get is ActiveX methods which work in a
very few cases.
|
by: vijaymohan |
last post by:
Hi ..I am very new to perl..can some one help me with this script pls..
I am Querying database and writing data to excel..
Here is my script:
#!/usr/bin/perl -w
use strict;
use DBI;
| |
by: bvithya |
last post by:
Hi Gurus,
I am in need of your guidance.
I have installed Perl5.8.8 on my server running with SunOS 5.8
and then I installed Spreadsheet::WriteExcel perl module. It has been installed successfully. Howver when I try to run a command to check whether it emails an excel sheet or not, it showed me the below.
# /home/oracle8/oradba/admin/utils/sqlplus2xls/sqlplus2xls.pl
ERROR (Missing Parameter): <config_file> not specified!
|
by: Perl Beginner |
last post by:
I am using Win32. I have created an excel spreadsheet, formatted the columns and rows, and would like to write to the cells…all of this using Spreadsheet::WriteExcel. My issue is, my script is very vast with a lot of subroutines, but I need the excel spreadsheet created in the main subroutine becasue this is where the data is that i want to capture. So if I create and format the spreadsheet within the main subroutine, and as it loops through,...
|
by: vijayarl |
last post by:
Hi Everyone,
Am trying to collate the individual xls files into a single xls file.i have written this code.
use strict;
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel::Big;
my $consol_rows=0;
|
by: somsub |
last post by:
Hi,
When I tried to open excel sheet created by below code with MSexcel it showing "Unable to read file " error .
use Spreadsheet::WriteExcel;
$workbook = Spreadsheet::WriteExcel->new("sm2.xls");
I am using winxp OS and MS excel 2003 ....
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |