Connecting Tech Pros Worldwide Forums | Help | Site Map

Not able to open excel sheet created by Spreadsheet::WriteExcel .

Newbie
 
Join Date: Nov 2008
Location: Bangalore
Posts: 15
#1: Oct 11 '09
Hi,

When I tried to open excel sheet created by below code with MSexcel it showing "Unable to read file " error .

Expand|Select|Wrap|Line Numbers
  1. use Spreadsheet::WriteExcel;
  2. $workbook = Spreadsheet::WriteExcel->new("sm2.xls");
  3.  
I am using winxp OS and MS excel 2003 ....


Advance thanks fr any help on this ..... its urgnt fr me...!!
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,569
#2: Oct 11 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


Quote:

Originally Posted by somsub View Post

Hi,

When I tried to open excel sheet created by below code with MSexcel it showing "Unable to read file " error .

Expand|Select|Wrap|Line Numbers
  1. use Spreadsheet::WriteExcel;
  2. $workbook = Spreadsheet::WriteExcel->new("sm2.xls");
  3.  
I am using winxp OS and MS excel 2003 ....


Advance thanks fr any help on this ..... its urgnt fr me...!!

As shown in the modules cpan page, did you try single quotes instead of double quotes? Also, check the path to the file to ensure its in the same location as the script.

Also, please use code tags when putting code in the forums.

Regards,

Jeff
Newbie
 
Join Date: Nov 2008
Location: Bangalore
Posts: 15
#3: Oct 11 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


yaa... !! I tried with single quote in the place of double quote but got the same "Unable to read file " error .
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,569
#4: Oct 11 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


Quote:

Originally Posted by somsub View Post

yaa... !! I tried with single quote in the place of double quote but got the same "Unable to read file " error .

Ok, what about the other suggestion... the path to the file? Is it located where the script is? If not, then you will probably have to tell the script that.
Newbie
 
Join Date: Nov 2008
Location: Bangalore
Posts: 15
#5: Oct 11 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


yaa.... It is located in the same folder where the script is . But I tried with different path also but got the same error .
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,569
#6: Oct 12 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


Ok, now that I have opened my eyes and reread your original question I can see you are trying to open the newly created file with Excel.

So, does the file that was created have a size other than zero? Also, the code you showed, is that all there is or did you create data and populate the workbook? If not, that may be the issue you are having.

Regards,

Jeff
Member
 
Join Date: Jun 2009
Posts: 54
#7: Oct 13 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


You need to show us more of your code.

Do you have any error handling on the file creation?

Are you populating the file with any data?

Did you explicitly close the file before trying to open it with Excel?

Are you manually opening the file in Excel or are you doing it in your script via Win32::OLE?
Newbie
 
Join Date: Nov 2008
Location: Bangalore
Posts: 15
#8: Oct 13 '09

re: Not able to open excel sheet created by Spreadsheet::WriteExcel .


Thanx guys fr ur interest and valuable inputs .....
As per your suggestion I added one more line that is "$workbook->close();"
to close it explicitly at the end of previously mentioned code . After the execution of this line i could able to open the excel sheet manually with MS excel with out any error.

Thanks a lot .
Reply