Javatpoint Logo
Javatpoint Logo

Perl with Excel File

Perl has few modules that can deal with excel files. It is able to handle all type of spreadsheets. You can create or read an excel file with the help of Perl very easily.


Perl Create Excel file

To create an excel file, we will use Perl module Excel::Writer::XLSX. The excel file extension is (.xlsx) for this module.

We are creating an excel file myExcel.xlsx with the above module. First we need to load the module. In the new constructor, we'll pass the file name we are creating. The output of new constructor is stored in $workbook.

An excel file consists of one or more than one sheet. Data is found on those sheets. We are creating sheets by calling add_worksheet() method of the $workbook object. Its return value is stored in $worksheet.

The write method adds data to the worksheet. Each call has two parameters. In excel, rows are marked from 1, and columns are marked from letters A, B, C and so on.

Lastly we close the file. But this is not necessary in Perl, as it automatically close file when script ends.

Output:

Perl With excel file 1

Perl Adding Formula in Excel

Now, we'll print 2's table by using multiplication. Column A will print 2's table.

Output:

Perl With excel file 2



Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA