Force download link on a google docs spreadsheet

前端 未结 3 628
旧巷少年郎
旧巷少年郎 2021-02-08 06:24

Is there a way to force a download link instead of the browser trying to open the file? In this case I have a docs spreadsheet and a some links to mp3 files. I want the users to

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-08 07:01

    To make download links for documents - https://docs.google.com/feeds/download/documents/Export?docID=yourDocId

    To make download links for any file - https://docs.google.com/uc?id=yourDocId&export=download&hl=en_US

    To make download links for spreadsheets - https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=yourDocId&exportFormat=csv

    For further information please go here


    UPDATING IN 2018

    The new download URL is
      https://docs.google.com/spreadsheets/d//export?gid=&format=csv
    where and can be obtained from your navigation's URL,
      https://docs.google.com/spreadsheets/d//edit#gid=

    PS: spreadsheets (workbook) may have multiple sheets (worksheets), GID is the desired sheet ID. One-sheet-spreadsheet usually has gid=0, but if you add more they'll have random numbers (the GID is preserved even changing tab-order).

    So, using wget or curl you can test,

       wget --no-check-certificate -O test.csv \
        'https://docs.google.com/spreadsheets/d/0At2sqNEgxTf3dEt5SXBTemZZM1gzQy1vLVFNRnludHc/export?gid=0&format=csv'
    

提交回复
热议问题