我需要边距参数才能将我的电子表格导出为 pdf。
我搜索了有关设置边距参数的信息,但找不到任何内容。以下参数运行良好。
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
+ '&size=A4' // paper size legal / letter / A4
+ '&portrait=false' // orientation, false for landscape
+ '&fitw=true&source=labnol' // fit to page width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenumbers=false&gridlines=false' // hide page numbers and gridlines
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='; // the sheet's Id
最佳答案
实际上,可以设置边距并创建 PDF。您只需要知道参数的名称及其可能的值。我已经让它与这些一起工作
参数:
&format=pdf //export format
&size=a4 //A3/A4/A5/B4/B5/letter/tabloid/legal/statement/executive/folio
&portrait=false //true= Potrait / false= Landscape
&scale=1 //1= Normal 100% / 2= Fit to width / 3= Fit to height / 4= Fit to Page
&top_margin=0.00 //All four margins must be set!
&bottom_margin=0.00 //All four margins must be set!
&left_margin=0.00 //All four margins must be set!
&right_margin=0.00 //All four margins must be set!
&gridlines=false //true/false
&printnotes=false //true/false
&pageorder=2 //1= Down, then over / 2= Over, then down
&horizontal_alignment=CENTER //LEFT/CENTER/RIGHT
&vertical_alignment=TOP //TOP/MIDDLE/BOTTOM
&printtitle=false //true/false
&sheetnames=false //true/false
&fzr=false //true/false
&fzc=false //true/false
&attachment=false //true/false
如您所见,用于 PDF 格式的参数比目前在 Internet 上流传的参数要多。是的,Google 似乎没有记录它们。
如果 PDF 导出失败,则可能是值不正确。某些参数对导出没有影响。例如:您正在使用
source=labnol
,这不是一个“真正的”参数,但它不会造成任何麻烦。确保您的 url 中有所有四个边距参数,如下所示:
&top_margin=0.00&bottom_margin=0.00&left_margin=0.00&right_margin=0.00
否则它不会创建 PDF。
希望有帮助!
关于google-apps-script - Google 电子表格导出为 PDF 的边距参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46088042/