1. Products
  2.   Spreadsheet
  3.   Perl
  4.   Spreadsheet-WriteExcel
 
  

Open Source Perl API to Work with Excel Binary Files

A Powerful Free Perl Excel Spreadsheet Library enables Software Developers to Create & Manipulate Excel Binary Files, Add Charts & Apply Formatting via free API.

What is Spreadsheet-WriteExcel?

Spreadsheets have long been a standard tool for organizing, displaying, and presenting data in the fields of data analysis and reporting. The Spreadsheet-WriteExcel library is one of the most robust and adaptable options among the several libraries for working with spreadsheets in Perl. For software developers who need to create Excel spreadsheets programmatically, the open source library is a great resource. The library generates an Excel file that works with Windows 97, 2000, 2002, and 2003.

Software developers can easily produce Excel spreadsheets with the Spreadsheet-WriteExcel Perl module. Because of its intuitive interface, both novice and experienced programmers can use it. By allowing us to create Excel files that work with different Excel versions, the library guarantees cross-platform compatibility. Creating cross-platform Excel binary files, adding multiple worksheets to a workbook, formatting cells, adding text and numbers, applying formula support, adding hyperlinks and images to cells, and many other functions are among the library's key features.

A great platform for creating dynamic, data-rich Excel spreadsheets in Perl is offered by the Spreadsheet-WriteExcel package. The module is compatible with most Macintosh, UNIX, and Windows operating systems. Furthermore, many Perl developers in the field of data processing and reporting choose the library due to its cross-platform interoperability and robustness. This package proved to be a dependable addition to our programming toolkit, whether we're using it for data management, report generation, or job automation. So, next time you find yourself faced with the challenge of creating Excel spreadsheets programmatically, consider employing the power of Spreadsheet-WriteExcel.

Previous Next

Getting Started with Spreadsheet-WriteExcel

The recommend way to install Spreadsheet-WriteExcel is using CPAN. Please use the following command for a smooth installation.

Install Spreadsheet-WriteExcel via CPAN

$ cpan Spreadsheet::WriteExcel 

You can also download it directly from GitHub.

Create a New Excel Workbook via Perl API

The open source Spreadsheet-WriteExcel library provides a user-friendly interface, making it accessible to both beginners and seasoned programmers. The library enables software developers to generate Excel files compatible with various Excel versions, ensuring compatibility across different platforms. The library allows users to add worksheets, format cells, insert charts, and include various elements like images, hyperlinks, formulas and so on. The library doesn't rely on any Microsoft Excel components, making it platform-independent and highly efficient for handling large datasets. The following example shows how to create a new Excel workbook using Perl code.

How to Create a New Excel Workbook using Perl API?

use Spreadsheet::WriteExcel;

# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new('example.xlsx');

# Add a worksheet
my $worksheet = $workbook->add_worksheet();

# Write data to cells
$worksheet->write('A1', 'Hello');
$worksheet->write('A2', 'Spreadsheet::WriteExcel');
$worksheet->write('B1', 'Welcome');
$worksheet->write('B2', 'to the world of Perl');

# Save the workbook
$workbook->close();

Apply Formatting Options via Perl API

The Spreadsheet-WriteExcel library makes it easy for software developers to open an existing spreadsheets and allows to format the data to enhance the visual appeal of the generated spreadsheet. To add data to a worksheet, you'll need to create a worksheet object and then write data to specific cells. The library provides several methods to format cells, such as setting font styles, cell alignment, background colors, customize cell borders, and may more. The following example demonstrates how software programmers can apply formatting to a worksheet cells inside Perl API.

How to Apply Formatting to Spreadsheet Cells using Perl Library?

my $worksheet = $workbook->add_worksheet('Sheet1');
$worksheet->write('A1', 'Hello');
$worksheet->write('A2', 'World');

# Formatting the cells
my $format = $workbook->add_format();
$format->set_bold();
$format->set_color('red');
$worksheet->write('A1', 'Hello', $format);

Add & Manage Charts in a Worksheet via Perl

Visualizing data is crucial for a better understanding of trends and patterns. The open source Spreadsheet-WriteExcel library supports the addition of charts to Excel worksheets. The library supports the creation of bar charts, line charts, pie charts, and more. The following example shows how software developers can add chart inside an Excel workbook using Perl commands.

How to Add Chart inside an Excel Workbook using Perl?

my $chart = $workbook->add_chart( type => 'column', embedded => 1 );
$chart->add_series( values => '=Sheet1!$A$1:$A$5' );
$worksheet->insert_chart('C1', $chart);
 English