Solved

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

Posted on 2004-08-23
4
924 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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