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 API enables software developers to create, edit & manipulate cross-platform Excel Binary Files for free.

In the world of data analysis and reporting, spreadsheets have long been a staple tool for organizing, visualizing, and presenting information. Among the various libraries available for working with spreadsheets in Perl, the Spreadsheet-WriteExcel library stands out as a powerful and versatile solution. The library is open source and serves as a valuable asset for software developers who need to generate Excel spreadsheets programmatically. The Excel file produced by the library is compatible with 97, 2000, 2002 and 2003.

Spreadsheet-WriteExcel is a Perl module that allows software developers to create Excel spreadsheets effortlessly. It provides a user-friendly interface, making it accessible to both beginners and seasoned programmers. The library enables us to generate Excel files compatible with various Excel versions, ensuring compatibility across different platforms. There are several important features part of the library such as creating cross-platform Excel binary files, adding multiple worksheets to a workbook, apply formatting to cells, inserting Text & numbers, applying formulas support, inserting hyperlinks and images to the cells and many more.

The Spreadsheet-WriteExcel library provides an excellent platform for generating dynamic and data-rich Excel spreadsheets in Perl. The module will work on the majority of Windows, UNIX and Macintosh platforms. Moreover, the library's robustness and cross-platform compatibility make it a preferred choice for many Perl developers in the realm of data processing and reporting. Whether it's generating reports, managing data, or automating tasks, this library proves itself as a reliable tool in our programming arsenal. 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.

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