Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now