Bootstrap FreeKB - Perl (Scripting) - Write to an Excel 95-2003 spreadsheet (xls)
Perl (Scripting) - Write to an Excel 95-2003 spreadsheet (xls)

Updated:   |  Perl (Scripting) articles

The Spreadsheet::WriteExcel module can be used to write data to an Excel spreadsheet. Be aware that this will overwrite the entire spreadsheet with the new data. If your goal is to instead append or replace data in an Excel spreadsheet, you will want to TBD.

Install the Spreadsheet::WriteExcel module. Import the Spreadsheet::WriteExcel module into your Perl script.

use Spreadsheet::WriteExcel;


These two lines are used to define the spreadsheet you are going to write to (example.xls in this example).

my $workbook = Spreadsheet::WriteExcel->new('example.xls');
my $worksheet = $workbook->add_worksheet();


This will write the text "Hello World" into cell A1 in Sheet1 of the Excel spreadsheet.

$worksheet->write('A1', 'Hello World');


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter a40e17 in the box below so that we can be sure you are a human.