csvgoogle-sheetsxlsx

Google Sheets export format set to CSV, downloads xlsx


I created a Google Sheet. It has one worksheet. I changed URL so it has export instead of edit and set ?format=csv. Here is the final URL:

https://docs.google.com/spreadsheets/d/{spreadsheet_id}/export?gid=0#gid=0?format=csv

It returns .xlsx file.

What am I doing wrong?


Solution

  • There are two instances of ? there. Use just one, like this:

    https://docs.google.com/spreadsheets/d/{ss_id}/export?format=csv
    

    You can also specify a sheet other than the first (default) sheet with &gid=..., like this:

    https://docs.google.com/spreadsheets/d/{ss_id}/export?format=csv&gid=123456
    

    To refer to a sheet by sheet name rather than by sheet id, or to refer to a specific range, use a query string:

    https://docs.google.com/spreadsheets/d/{ss_id}/gviz/tq?tqx=out:csv&sheet=Sheet1
    
    https://docs.google.com/spreadsheets/d/{ss_id}/gviz/tq?tqx=out:csv&range=B2:D42
    

    Query strings also let you filter and aggregate data.

    Also see Download and export files.