in reply to Re: Spreadsheet::WriteExcel, rotate text
in thread Spreadsheet::WriteExcel, rotate text

Thank you for your help. I have found another problem and then subsequently a solution for the writing vertically in a merged column. The trick is to write what you want to the destination cell and then merge the cells. If you merge them first and then write the data to the beginning cell of the merged column it only registers as being written to that cell and it is treated as though it is in a single cell rather than a merged column. Here is the working code:
#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; # Variables my $file_name = 'switch_report.xls'; my $sheet_title='Traffic Estimations Report -May 2002'; my @array=( ['Switch 1','','above cell blank','456','789'], ['Switch 2','DEF','GHI'] ); #print $1; #my $array_ref=\$1; my $array_ref=\@array; # Create a new Excel workbook my $workbook = Spreadsheet::WriteExcel->new($file_name); # Add a worksheet my $worksheet = $workbook->addworksheet(); $worksheet->fit_to_pages(1,1); $worksheet->set_landscape(); $worksheet->set_margins(.25); # Add formats my $cb_format = $workbook->addformat(); # Add a format my $rotation_format = $workbook->addformat(); # Define Formats # $cb_format $cb_format->set_bold(); $cb_format->set_italic(); $cb_format->set_underline(); $cb_format->set_align('center'); $cb_format->set_size(18); # $rotation_format $rotation_format->set_rotation(2); $rotation_format->set_bold(); $rotation_format->set_align('vcenter'); # Write to the worksheet $worksheet->write(0,1,$sheet_title, $cb_format); $worksheet->merge_cells(0,1,2,29); $worksheet->merge_cells(3,1,3,29); #$worksheet->write_row(11,1,$array_ref); $worksheet->write(4,0,"Day of the month",$rotation_format); $worksheet->merge_cells(4,0,37,0); # write_switch_data my $row = 4; my $col = 1; $worksheet->write_row($row, $col, $array_ref);

Replies are listed 'Best First'.
Re: Re: Re: Spreadsheet::WriteExcel, rotate text
by jmcnamara (Monsignor) on Jul 11, 2002 at 23:15 UTC

    That's interesting. If you don't mind I'll add it to the Spreadsheet::WriteExcel documentation.

    It doesn't work with Excel 97 but it is still very useful.

    Thanks.
    --
    John.

      Thanks, that would be great. I would love to see it added as a tip. I know that if I could not have done it I would have been completely stuck. I am automating a process that is done by hand at this time and (for the sake of the endusers) has to look the same as it did before.