.. _vector.xlsx:

================================================================================
XLSX - MS Office Open XML spreadsheet
================================================================================

.. shortname:: XLSX

.. build_dependencies:: libexpat

This driver can read, write and update spreadsheets in Microsoft Office
Open XML (a.k.a. OOXML) spreadsheet format, generated by applications
like Microsoft Office 2007 and later versions. LibreOffice/OpenOffice
can also export documents in that format since their v3 version.

The driver is only available if GDAL/OGR is compiled against the Expat
library.

Each sheet is presented as a OGR layer. No geometry support is available
directly (but you may use the OGR VRT capabilities for that).

Note 1 : depending on the application that produced the file, the driver
might succeed or not in retrieving the result of formulas. Some
applications write the evaluated result of formulas in the document, in
which case the driver will be able to retrieve it. Otherwise the raw
formula string will be returned.

Note 2 : spreadsheets with passwords are not supported.

Note 3 : when updating an existing document, all existing styles,
formatting, formulas and other concepts (charts, drawings, macros, ...)
not understood by OGR will be lost : the document is re-written from
scratch from the OGR data model.

Driver capabilities
-------------------

.. supports_create::

.. supports_virtualio::

Open options
------------

|about-open-options|
The following open options are available:

-  .. oo:: HEADERS
      :choices: FORCE, DISABLE, AUTO
      :default: AUTO
      :since: 3.8

      By default, the driver
      will read the first lines of each sheet to detect if the first line
      might be the name of columns. If set to FORCE, the driver will
      consider the first line as the header line. If set to
      DISABLE, it will be considered as the first feature. Otherwise
      auto-detection will occur.

-  .. oo:: FIELD_TYPES
      :choices: STRING, AUTO
      :default: AUTO
      :since: 3.8

      By default, the driver will
      try to detect the data type of fields. If set to STRING, all fields
      will be of String type.


Configuration options
---------------------

|about-config-options|
The following configuration options are available:

-  .. config:: OGR_XLSX_HEADERS
      :choices: FORCE, DISABLE, AUTO
      :default: AUTO

      By default, the driver
      will read the first lines of each sheet to detect if the first line
      might be the name of columns. If set to FORCE, the driver will
      consider the first line as the header line. If set to
      DISABLE, it will be considered as the first feature. Otherwise
      auto-detection will occur.

-  .. config:: OGR_XLSX_FIELD_TYPES
      :choices: STRING, AUTO
      :default: AUTO

      By default, the driver will
      try to detect the data type of fields. If set to STRING, all fields
      will be of String type.

Examples
--------

-  Transform CSV file input.csv to an Office Open XML file output.xlsx.
   The spreadsheet will contain one sheet with name "input".

   ::

      ogr2ogr -f "XLSX" output.xlsx input.csv

-  Add the contents of CSV file input2.csv to the OOXML file output.xlsx
   created in the first example. The spreadsheet will now contain two
   sheets, "input" and "input2".

   ::

      ogr2ogr -f "XLSX" output.xlsx -update input2.csv

