in reply to Color highlighting in Excel


Here is a short example that matches an identifier and highlights it within the line written to an Excel file.

It used Spreadsheet::WriteExcelXML because this type of in-string highlighting isn't (currently) possible with Spreadsheet::WriteExcel. This means, however, that the end user must have Excel 2002/2003.

#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcelXML; my $workbook = Spreadsheet::WriteExcelXML->new("file.xls"); my $worksheet = $workbook->add_worksheet(); my $ident = 'days'; my $row = 0; while (<DATA>) { if (s[\b($ident)\b][<B>$1</B>]og) { chomp; $worksheet->write_html_string($row++, 0, $_); } } __DATA__ These are the days and these are the days. What are days for? This is the time. And this is the record of the time. I thank you for the days.

--
John.

Replies are listed 'Best First'.
Re^2: Color highlighting in Excel
by imperl (Novice) on Sep 19, 2005 at 08:27 UTC
    The file gets terminated at the second line, since its unable to find Spreadsheet::WriteExcelXML or evern Spreadsheet::WriteExcel. Do I need to add WriteExcel into the repository.

      That error means that the module hasn't been installed.

      There are installation instructions for Spreadsheet::WriteExcel here. The first two methods also apply to Spreadsheet::WriteExcelXML.

      With ActivePerl you can also install the modules via ppm from the ActiveState repositories.

      See also Writing, Installing, and Using Perl Modules.

      --
      John.

        I had tried installing it from the links you mentioned but do these work on Win XP machines since these are tar.gz files?