Solved

Spreadsheet::WriteExcel, win32::OLE, Win32::ctrlGUI

Posted on 2004-08-23
4
926 Views
Last Modified: 2008-01-09
I seem to be having difficulties with Spreadsheet::WriteExcel, The problem is with the formatting of some of the cells.

my $baseformat = $workbook->addformat();
$baseformat->set_align('center');
$baseformat->set_border(1);
$baseformat->set_border_color('black');

my $bformat = $workbook->addformat();
$bformat->set_bold();
$bformat->set_align('center');
$bformat->set_border(1);
$bformat->set_border_color('black');

my $formatmonth = $workbook->addformat();
$formatmonth->set_align('center');
$formatmonth->set_border(1);
$formatmonth->set_border_color('black');
$formatmonth->set_num_format('mmm-yy');

my $bformatmonth = $workbook->addformat();
$bformatmonth->set_bold();
$bformatmonth->set_align('center');
$bformatmonth->set_border(1);
$bformatmonth->set_border_color('black');
$bformatmonth->set_num_format('mmm-yy');

my $format1 = $workbook->addformat();
$format1->set_color('white');
$format1->set_bold();
$format1->set_size(15);
$format1->set_fg_color('black');
$format1->set_align('center');

the $bformat is the one causing problems.  With other programs I have been using as examples thye can use several different formats for whatever they want yet for this program I cannot.

I can write the excel file and then open the file in Excel and the program shuts down on me when I run my mouse over one of the cells?!?  But if I don't run my mouse over any of the cells and save the file, close it, then reopen it all of the cells are proper and the formatting is correct.

So my thought is to write the file using Spreadsheet::writeexcel  open the filw with win32::OLE to resave the program and then reopen the file and use Win32::ctrlgui to print the file on a printer.  Please help.
0
Comment
Question by:ralphsauto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
inq123 earned 100 total points
ID: 11882119
Hi ralphsauto,

It must be some other code or coding sequence/module/computer problem that you were experiencing.  I've tested the following code for your $bformat and it had no problem at all:

use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Utility;

my $workbook = Spreadsheet::WriteExcel->new("test.xls");

my $bformat = $workbook->addformat();
$bformat->set_bold();
$bformat->set_align('center');
$bformat->set_border(1);
$bformat->set_border_color('black');

my $sheet = $workbook->addworksheet('test');
for my $i (1..10)
{
  $sheet->write(1, $i, $i, $bformat);
}

Cheers!
0
 

Author Comment

by:ralphsauto
ID: 11884015
The $bformat works very well with parts of the program but not with all the parts of the program.

I have changed all the writes to write_url, write_string write_number etc and it still doesn't work unless I open and save the file first, so I have used the Win32::OLE module to do that and it does save the file properly.  So now all I need help with is opening the file and using Win32::ctrlGUI to print the document then closing it.

Thanks for your help so far.
0
 
LVL 8

Expert Comment

by:inq123
ID: 11884098
" The $bformat works very well with parts of the program but not with all the parts of the program." --- need example.

Never used Win32::ctrlGUI before, but my guess is that the documentation should be enough for the simple task that you wanted to do?
0
 

Author Comment

by:ralphsauto
ID: 11884809
No worries you are right very smiple to use.  Thanks for your help.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl script 4 115
Perl output collect 7 69
Is it true to say that Python is successor of Perl? 7 208
Create an automated page index 9 77
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question