# perldoc > Spreadsheet::XLSX

yaml
---
type: CommandReference
command: Spreadsheet::XLSX
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference

- `Spreadsheet::XLSX->new($filename, $converter)` — open an Excel 2007 (.xlsx) file; optional `$converter` is an object with a `convert` method (e.g., `Text::Iconv`) for encoding conversion
- `$excel->{Worksheet}` — array of worksheet objects, each with `{Name}`, `{MinRow}`, `{MaxRow}`, `{MinCol}`, `{MaxCol}`, and `{Cells}[$row][$col]`
- `$cell->{Val}` — cell value

## Name

Spreadsheet::XLSX - Perl extension for reading MS Excel 2007 files

## Synopsis

perl
use Text::Iconv;
my $converter = Text::Iconv->new("utf-8", "windows-1251");

# Text::Iconv is not required. Any object with a convert method works, or nothing.

use Spreadsheet::XLSX;

my $excel = Spreadsheet::XLSX->new('test.xlsx', $converter);

foreach my $sheet (@{$excel->{Worksheet}}) {
    printf("Sheet: %s\n", $sheet->{Name});

    $sheet->{MaxRow} ||= $sheet->{MinRow};

    foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) {
        $sheet->{MaxCol} ||= $sheet->{MinCol};

        foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) {
            my $cell = $sheet->{Cells}[$row][$col];

            if ($cell) {
                printf("( %s , %s ) => %s\n", $row, $col, $cell->{Val});
            }
        }
    }
}
## Description

This module is a quick and dirty emulation of [Spreadsheet::ParseExcel](https://metacpan.org/pod/Spreadsheet::ParseExcel) for Excel 2007 (.xlsx) file format. It supports styles and many of Excel's quirks, but not all. It populates the classes from Spreadsheet::ParseExcel for interoperability, including Workbook, Worksheet, and Cell.

## Options

- `$converter` — optional object with a `convert` method used for character encoding (e.g., `Text::Iconv`). If omitted, no conversion is applied.

## Examples

The synopsis above is the primary example. It demonstrates opening a file, iterating over worksheets, rows, and cells, and printing cell values.

## See Also

- [Spreadsheet::ParseXLSX](https://metacpan.org/pod/Spreadsheet::ParseXLSX) — a more reliable parser for .xlsx files; recommended over this module
- [Spreadsheet::ParseExcel](https://metacpan.org/pod/Spreadsheet::ParseExcel) — the original parser for .xls files
- [Text::CSV_XS](https://metacpan.org/pod/Text::CSV_XS), [Text::CSV_PP](https://metacpan.org/pod/Text::CSV_PP) — CSV handling
- [Spreadsheet::ReadSXC](https://metacpan.org/pod/Spreadsheet::ReadSXC), [Spreadsheet::BasicRead](https://metacpan.org/pod/Spreadsheet::BasicRead) — other spreadsheet readers
- [Spreadsheet::ConvertAA](https://metacpan.org/pod/Spreadsheet::ConvertAA) — alternative cell/column conversion
- [Spreadsheet::Perl](https://metacpan.org/pod/Spreadsheet::Perl) — pure Perl spreadsheet engine
- [Spreadsheet::Read](https://metacpan.org/pod/Spreadsheet::Read) — interface module for reading spreadsheet data
- [xls2csv](https://metacpan.org/release/KEN/xls2csv-1.07) — alternative tool for converting Excel to CSV with encoding support
