1#!/usr/bin/perl -w 2 3############################################################################### 4# 5# This example demonstrates html formatted strings in cells. 6# 7# reverse('�'), April 2005, John McNamara, jmcnamara@cpan.org 8# 9 10use strict; 11use Spreadsheet::WriteExcelXML; 12 13my $workbook = Spreadsheet::WriteExcelXML->new("html_string.xls"); 14my $worksheet = $workbook->add_worksheet(); 15 16$worksheet->set_column('B:B', 25); 17 18 19# Write a string with some bold and italic text. Cell formatting can also 20# be added. 21# 22my $str1 = 'Some <B>bold</B> and <I>italic</I> text'; 23my $format1 = $workbook->add_format(fg_color => 'yellow', border => 6); 24 25$worksheet->write_html_string('B2', $str1); 26$worksheet->write_html_string('B4', $str1, $format1); 27 28 29# Write a string with subscript and superscript. Also increase the font 30# size to make it more visible. 31# 32my $str2 = 'x<Sub><I>j</I></Sub><Sup>(n-1)</Sup>'; 33my $format2 = $workbook->add_format(size => 20); 34 35$worksheet->write_html_string('B6', $str2, $format2); 36 37# Write a multicoloured string. 38# 39my $str3 = '<Font html:Color="#FF0000">Red</Font>' . 40 '<Font> and </Font>' . 41 '<Font html:Color="#0000FF">Blue</Font>'; 42 43$worksheet->write_html_string('B8', $str3); 44 45 46__END__ 47