> ## Documentation Index
> Fetch the complete documentation index at: https://sdk.grid.is/llms.txt
> Use this file to discover all available pages before exploring further.

# Export workbook as an .xlsx file

> Export a workbook as an .xlsx file. Cells can be updated before the
workbook is exported.



## OpenAPI

````yaml post /v1/workbooks/{id}/export
openapi: 3.1.0
info:
  title: GRID API
  summary: Spreadsheets run the world. Now you can run spreadsheets.
  description: >-
    GRID's API transforms spreadsheets into powerful, programmable APIs. Our
    platform supports seamless integration of spreadsheet data into your
    applications, supporting dynamic interactions with spreadsheets, including
    real-time data querying with ephemeral updates.
  version: 1.0.0
servers:
  - url: https://api.grid.is
security: []
tags:
  - name: workbooks
    description: Interact with workbooks and their data
paths:
  /v1/workbooks/{id}/export:
    post:
      tags:
        - workbooks
      summary: Export workbook as an .xlsx file
      description: |-
        Export a workbook as an .xlsx file. Cells can be updated before the
        workbook is exported.
      operationId: export_workbook
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: Unique workbook id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportRequest'
      responses:
        '200':
          description: Workbook exported as an .xlsx file
          content:
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '400':
          description: Error returned when you make a bad request
          content:
            application/json:
              example:
                error_code: invalid_json
                error_message: Bad request
                error_details: RequestJsonParsingFailed
        '403':
          description: Error returned when you don't have permission to query a workbook
          content:
            application/json:
              example:
                error_message: Forbidden
                error_details: Only API keys can access the workbook engine API
        '429':
          description: Error returned when you exceed your API rate limit
          content:
            application/json:
              example:
                error_code: rate_limit_exceeded
                error_message: Rate limit exceeded
                error_details: 'Retry after: 60'
      security:
        - apiKey: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Grid from '@grid-is/api';

            const client = new Grid({
              apiKey: 'My API Key',
            });

            const response = await client.workbooks.export('id');

            console.log(response);

            const content = await response.blob();
            console.log(content);
        - lang: Python
          source: |-
            from grid_api import Grid

            client = Grid(
                api_key="My API Key",
            )
            response = client.workbooks.export(
                id="id",
            )
            print(response)
            content = response.read()
            print(content)
        - lang: Java
          source: |-
            package is.grid.api.example;

            import is.grid.api.client.GridClient;
            import is.grid.api.client.okhttp.GridOkHttpClient;
            import is.grid.api.core.http.HttpResponse;
            import is.grid.api.models.workbooks.WorkbookExportParams;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    GridClient client = GridOkHttpClient.fromEnv();

                    HttpResponse response = client.workbooks().export("id");
                }
            }
components:
  schemas:
    ExportRequest:
      properties:
        apply:
          anyOf:
            - items:
                $ref: '#/components/schemas/DataTransformation'
              type: array
            - type: 'null'
          title: Apply
          description: Cells to update before exporting.
          examples:
            - - target: A2
                value: 1234
        goalSeek:
          anyOf:
            - $ref: '#/components/schemas/QueryRequestGoalSeek'
            - type: 'null'
          description: >-
            Goal seek. Use this to calculate the required input value for a
            formula to achieve a specified target result. Useful when the
            desired outcome is known, but the corresponding input is not
      type: object
      title: ExportRequest
      description: >-
        Request body for exporting a workbook as an .xlsx file. Cells can be

        updated before reading the workbook, and a goal seek function can be
        used

        to calculate the required input value for a formula to achieve a
        specified

        target result.
      examples:
        - apply:
            - target: A2
              value: 1234
          read:
            - A1:A4
    DataTransformation:
      properties:
        target:
          anyOf:
            - type: string
              description: A1-style string reference with optional sheet prefix
              examples:
                - Sheet1!A1:B2
                - '''Loan Calculator''!C32'
            - $ref: '#/components/schemas/ReferenceObject'
          title: Target
          description: Reference for the cell to write to
        value:
          anyOf:
            - type: integer
            - type: number
            - type: string
            - type: boolean
            - type: 'null'
          title: Value
          description: Value to write to the target cell
      type: object
      required:
        - target
        - value
      title: DataTransformation
      description: >-
        Specifies a temporary change to a workbook cell, including the `target`
        cell reference and the

        `value` to apply. The API has no state, and so any changes made are
        cleared after each request.
    QueryRequestGoalSeek:
      properties:
        targetCell:
          anyOf:
            - type: string
              description: A1-style string reference with optional sheet prefix
              examples:
                - Sheet1!A1:B2
                - '''Loan Calculator''!C32'
            - $ref: '#/components/schemas/ReferenceObject'
          title: Target cell
          description: Reference for the cell that contains the formula you want to resolve
        targetValue:
          anyOf:
            - type: integer
            - type: number
          title: Target value
          description: The value you want the formula to return
        controlCell:
          anyOf:
            - type: string
              description: A1-style string reference with optional sheet prefix
              examples:
                - Sheet1!A1:B2
                - '''Loan Calculator''!C32'
            - $ref: '#/components/schemas/ReferenceObject'
          title: Control cell
          description: Reference for the cell that will contain the solution
      type: object
      required:
        - targetCell
        - targetValue
        - controlCell
      title: QueryRequestGoalSeek
      description: >-
        Goal seek. Use this to calculate the required input value for a formula
        to achieve a specified

        target result. This is particularly useful when the desired outcome is
        known, but the

        corresponding input is not.
    ReferenceObject:
      properties:
        cells:
          type: string
          title: Cells
          description: Unprefixed A1-style range, id, or name
          examples:
            - A1:B2
            - C32
            - name
        sheet:
          anyOf:
            - type: string
            - type: 'null'
          title: Sheet
          description: Name of the sheet to reference
          examples:
            - Sheet1
            - Loan Calculator
      type: object
      required:
        - cells
        - sheet
      title: ReferenceObject
      description: A reference to a range of spreadsheet cells.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````