473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to add a sheet to an existing excel file?

Tried googling and got maybe some older examples of how to solve this problem. But when I tried they didn't seem to work.
I'm able to create and write to a new file but not sure how to edit an existing one.
Expand|Select|Wrap|Line Numbers
  1. ## open excel ##
  2. if (! -e "$name"){
  3. # Create a new workbook if file doesn't exist.  
  4. my $workbook  = Spreadsheet::WriteExcel->new("$name");
  5. my $worksheet1 = $workbook->add_worksheet('WW01');
  6. $worksheet1->write(0, 0,  'Hi Excel!');
  7. }
  8. else{
  9. #edit existing one
  10.  
  11.  
  12.  }
  13.  
Jan 19 '11 #1
4 7056
Rabbit
12,516 Expert Mod 8TB
I don't know if this will work but if you are able to do ->new() to create a new workbook. Couldn't you use a ->open() to open a workbook?
Jan 19 '11 #2
RonB
589 Expert Mod 512MB
Have you read the documentation for the module?

This module cannot be used to write to an existing Excel file (See "MODIFYING AND REWRITING EXCEL FILES").
http://search.cpan.org/~jmcnamara/Sp...NG_EXCEL_FILES
Jan 20 '11 #3
chorny
80 Expert
use Spreadsheet::ParseExcel
Jan 26 '11 #4
miller
1,089 Expert 1GB
As the guys here have already said, you can't use Spreadsheet::WriteExcel to write to an already existing spreadsheet. Instead you must use Spreadsheet::ParseExcel to read in the file and create a new on using Spreadsheet::WriteExcel. After you've done that you can move the newly created file over the old file.

- Miller
Jan 27 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mr Marsh | last post by:
Hello, I'll try and provide as much information as I can about the problem/challenge I'm facing. I have found similar postings to my enquiry but they don't really hit the nail on the head. I am...
0
by: Zero | last post by:
how to Overwrite Existing Excel File without prompt and quit?
1
by: BigAbility | last post by:
hi all, i am trying to make a excel file that is consist of multiple sheets now i did that downlaod excel file from the web server. but it's not multiple sheets, so i realize that i have...
1
by: tanilov | last post by:
Hi all, I need to read data from an excel file and populate a dataset. After some search I found following code: connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +...
6
by: jcf378 | last post by:
hello-- i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the...
5
by: Aspgm | last post by:
Hi Everyone, I have an Excel file to update on-line using ASP. I could write data to a fresh excel file. But I couldn't find a way to open an existing Excel file and update relevant cells. If...
1
by: fluff | last post by:
Hello I'm not sure if this is not the right forum for this question so sorry if it is not (I was just told at the html forum to try a different forum) Is there a way to connect to an excel file...
1
by: egrill | last post by:
I have an Excel file that needs to be updated nightly and sent to a user. I can't find anyway using the existing marcos that would allow me to set a automated command to run the query on a scheduled...
3
by: thanawala27 | last post by:
Hi, I had problems writing in an existing Excel File. There is an excel file with a worksheet. I would like to open this existing Excel file and add another worksheet and write data into it....
3
by: premMS143 | last post by:
How to append Data to an existing Excel file? means, I'm using VB as front end & once I exported the data to Excel file & saved it as 'ABC.xls'. Now, the question/doubt is; I addded some more...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.