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

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');


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |