API
  • API Index
  • Batch API
  • Content Negotiation
  • Dynamic Paths
  • Hierarchy API
  • List API
  • Quick Reference
  • Time Series API
  • Views
    • Configuration
  • Overview
  • Application Configuration
  • Documentation Configuration
  • Spec Configuration
    • Features
  • API Testing
  • Asynchronous Processing
  • Cassandra Time-Series Engine
  • Cassandra Integration
  • Default Controller Customisation
  • Documentation
  • Geospatial Filtering
  • Model Documentation
  • PostgreSQL Integration
  • Excel Spreadsheet Format
    • Tutorials
  • Step-by-Step Guide
  • Archetype Setup
  • Logging
  • Prometheus
  • Sentry Logging
    • UI Customisation
  • UI Customisation
  • SASS Build Chain
  • Shared Layout
  • API Documentation
  • Model Documentation
  • Results
  • sapi-nt v current

    Excel Spreadsheet Format

    Sapi-NT can format API responses in Excel spreadsheet format (XLS), which is compatible with spreadsheet applications such as Microsoft Excel and OpenOffice Calc. This document describes how to configure a Sapi-NT application to produce API responses in XLS format.

    Configure Sapi-NT

    To enable XLS format, you must first add the following dependency to the pom.xml file of your Sapi-NT Maven project.

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.0.0</version>
    </dependency>
    

    Then, edit your ApplicationRunner class (the class annotated with @SpringBootApplication) to call ConfigProperties.enableXLS() in the run method:

    override fun run(args: ApplicationArguments?) {
        log.info("API at ${api.apiProperties.baseURI} - ${api.apiProperties.comment}")
        ConfigProperties.enableXLS()
        log.info("XLS format enabled.")
    }
    

    Configure Views

    API responses in XLS format produce the same columns and rows as the CSV format, which is determined by the requested view definition (or the default view if the request does not specify a view). The csv.map and cav.flatPaths properties apply to both CSV and XLS responses.

    To configure a view, you must edit either the view spec file or the endpoint spec file containing the embedded view.

    Request XLS Format

    When the XLS format is configured, API consumers can request XLS responses with the usual content negotiation methods, specifying either the name or media type as follows:

    Name Media Type
    xls application/vnd.openxmlformats-officedocument.spreadsheetml.sheet