• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 940
  • Last Modified:

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

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
ralphsauto
Asked:
ralphsauto
  • 2
  • 2
1 Solution
 
inq123Commented:
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
 
ralphsautoAuthor Commented:
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
 
inq123Commented:
" 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
 
ralphsautoAuthor Commented:
No worries you are right very smiple to use.  Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now