473,402 Members | 2,050 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,402 software developers and data experts.

SaveAs function doubt

170 100+
Hi guys,

need yr help on a certain command


$book->SaveAs ("C:\\Documents and Settings\\clong\\Desktop\\perl\\$save_file_name.xl s")

the above statement in perl save my file to the directory in my desktop as "perl"
however the problem with the statement is if the file "perl" exist the file contain my program "$save_file_name.xls" exists then,

but when the folder perl is not created, this SaveAs function doesn't seem to able to create a new folder "perl" by itself, instead it saves to a default directory, how do i actually then save "$save_file_name.xls" to the directory above even when the folder "perl" is not created?

thanks
Feb 12 '08 #1
5 1823
eWish
971 Expert 512MB
If the module you are using does not have an alternative solution you could always do a test and see if the directory exists. If the directory does not exists then just create it before you save the file.

perldoc -X

--Kevin
Feb 12 '08 #2
nithinpes
410 Expert 256MB
Hi guys,

need yr help on a certain command

$book->SaveAs ("C:\\Documents and Settings\\clong\\Desktop\\perl\\$save_file_name.xl s")

the above statement in perl save my file to the directory in my desktop as "perl"
however the problem with the statement is if the file "perl" exist the file contain my program "$save_file_name.xls" exists then,

but when the folder perl is not created, this SaveAs function doesn't seem to able to create a new folder "perl" by itself, instead it saves to a default directory, how do i actually then save "$save_file_name.xls" to the directory above even when the folder "perl" is not created?

thanks

You can use the folowing line to create directory after checking for its existence:

Expand|Select|Wrap|Line Numbers
  1.  
  2. mkdir("C:\\Documents and Settings\\clong\\Desktop\\perl") unless(-e "C:\\Documents and Settings\\clong\\Desktop\\perl") ;
  3.  
  4.  
Feb 12 '08 #3
poolboi
170 100+
You can use the folowing line to create directory after checking for its existence:

Expand|Select|Wrap|Line Numbers
  1.  
  2. mkdir("C:\\Documents and Settings\\clong\\Desktop\\perl") unless(-e "C:\\Documents and Settings\\clong\\Desktop\\perl") ;
  3.  
  4.  

Thanks a lot for all yr help
:)
Feb 12 '08 #4
KevinADC
4,059 Expert 2GB
You can use the folowing line to create directory after checking for its existence:

Expand|Select|Wrap|Line Numbers
  1.  
  2. mkdir("C:\\Documents and Settings\\clong\\Desktop\\perl") unless(-e "C:\\Documents and Settings\\clong\\Desktop\\perl") ;
  3.  
  4.  

You don't really need the test. Either the directory will be created or it won't. The problem with that code is if the mkdir() function fails and the directory does not exist, you will never know what happened. Might be a small chance of that happening but it is a good habit to always check the success/failure of system level functions.
Feb 12 '08 #5
poolboi
170 100+
You don't really need the test. Either the directory will be created or it won't. The problem with that code is if the mkdir() function fails and the directory does not exist, you will never know what happened. Might be a small chance of that happening but it is a good habit to always check the success/failure of system level functions.
hm..ok thanks
but in any case
the code mkdir() works in my program now..so it's able to create a folder and save an excel file inside
Feb 12 '08 #6

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

Similar topics

0
by: | last post by:
Hi, I am trying to allow my Intranet users to upload their Microsoft Office Documents and then have them viewed as .html files. So far, through COM i am able to get WORD documents to convert...
0
by: Simon | last post by:
Hi, I need help on how to save data to a text file or spreadsheet via the SaveAs diaglog. I want to click a button on the front end, but go to the backend to query the database. With the...
0
by: TOM | last post by:
I want to saveas silently ! it will not prompt to user for saveas please tell me how can I do this silently. please do replay ! OLEObject IE IE = CREATE OLEObject
5
by: Reddy | last post by:
System.Web.UI.HtmlControls.HtmlInputFile.SaveAs(FileName) is not overwriting the file. It used to work fine on IIS5.1 Recently we migrated to IIS6.0. Since then it's not working. If it's new file...
0
by: mandogon | last post by:
what i want to do is instead of saving a file in a particular predefine section i want a save as diolog box to come up and ask me to put the file name in this is what i have so far but cant get the...
2
by: Lance Hoffmeyer | last post by:
Hey all, As always, thanks in advance! I am trying to save a ppt presentation but am having problems regarding spaces and am wondering if I am doing something wrong or whether this is a bug?...
17
by: jschmidt | last post by:
Hello everyone, I have a button on a form that calls a function to populate some textboxes with where criteria that is used in a parameterized query this is then used as the table source for a...
6
by: mrobinson86 | last post by:
Hey guys, wondered if anybody could help me out with a pretty simple piece of code that has been driving me crazy for the past few days? I am trying to create a client side self sustaining message...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
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...
0
tracyyun
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...
0
isladogs
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...

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.