Perl Create Excel File
w3hello.com logo
Perl Basics
Perl Introduction
Perl Installation
Perl Comments
Perl String
Perl Operators
Perl Variables
Perl Arrays
Perl do...while Loop
Perl Environment
Perl Syntax Overview
Perl while Loop
Perl Array with Loops
Perl IF...ELSE statement
Perl IF Statement
Perl if-else
Perl foreach Loop
Perl for Loop
Perl continue Statement
Perl nested Loop
Perl until Loop
Perl next Statement
Perl Array
Perl Loops
Perl File I/O
Perl goto
Perl Socket Programming
Perl Error Handling
Perl Directories
Perl Process Management
Perl stdin
Real Device Vs Emulator Testing: Ultimate Showdown
Perl Formats Writing Reports
Perl Regular Expressions
Perl Create Excel File
A complete guide to CSTE certification
Perl Hashes
Perl Special Variables
Perl do-while Loop
Perl Chop() Vs Chomp()
The Perl DBI
Perl IF...ELSIF statement
Perl print() and say()
Perl Database Access
Perl Formats
Perl last Statement
Perl UNLESS...ELSE statement
Perl Scalars
How to organize Requirements as a Business Analyst
Perl Packages and Modules
Perl goto Statement
Perl Object Oriented
Perl Subroutines
Perl redo Statement
Perl Command Line Arguments | argv
Perl String Escaping Characters
Perl Date and Time
Perl Modules and namespaces
Perl UNLESS...ELSIF statement
Perl Conditional Statements IF...ELSE
Perl Functions and Subroutines
Perl Sending Email
Perl DBI
Perl Versions
Top 100 QTP Interview Questions & Answers
Perl Operator Types
Perl switch Statement
Perl File handling
Perl References
Perl CGI Programming
Object Oriented Programming in PERL
Perl switch
Perl Interview Questions
How PERL is used in Automation Testing
Perl Functions References
Perl Multidimensional Array
Perl unless Statement
Perl Basics
Previous : Perl Regular Expressions Next : A complete guide to CSTE certification

Perl Create 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
Previous : Perl Regular Expressions Next : A complete guide to CSTE certification
© Copyright 2018 W3Hello Publishing Limited. All rights reserved.
Contact us | Sitemap