在Google Apps脚本中将范围导出为PDF [英] Export a range as a PDF in Google Apps Script

查看:114
本文介绍了在Google Apps脚本中将范围导出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了一些能够完成我想要的代码的代码,但我对Google应用程序脚本的工作原理太陌生。我只用微软的excel编码,虽然我没有完全丢失,但我仍然很迷茫。



我正在寻找代码来选择范围,然后将选择下载为...选择为PDF,适合宽度,纵向,无网格。理想情况下,这个PDF可以发送到我的桌面上的特定文件夹,但我不知道这些应用程序脚本是否支持。



我找到了需要的方法我认为)建立宽度,肖像,没有网格。我所做的所有其他搜索将整个工作表转换为PDF并发送给我,这不是我想要做的,我找不到要删除的示例代码的哪些部分,因为它看起来像PDFs被识别为web地址。任何帮助将不胜感激。

解决方案

似乎没有直接的方法来将Range转换为PDF(blob) Google Apps脚本。您可以做的最好的做法是将范围值复制到空白电子表格,应用您的格式,然后导出该表格。



您可以将PDF写入Google云端硬盘中的文件夹,然后使用计算机上的Drive软件将该文件夹与桌面上的文件夹同步完成最后一部分。



我没有这样简单的代码片段,但是这里有相关的文档链接:



https://developers.google.com/apps-script/reference / spreadsheet / range#getvalues

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#create(String)



https://开发人员。 google.com/apps-script/reference/spreadsheet/range#setValues(Object)



https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#get As(String)



https://developers.google.com/apps-script/reference/drive/drive-app#createFile(String,String,String)


I've searched all over for some lines of code that would accomplish what I want, but I'm too unfamiliar with how google apps script works. I've only ever coded in Microsoft excel and although I'm not completely lost, I'm still pretty lost.

I am looking for code that would select a range, then "Download as.." the selection to PDF, fit width, portrait, no grid. Ideally this PDF could be sent to a specific folder on my desktop, but I don't know if the apps script supports that.

I've found the methods needed (I think) to establish the width, portrait, no grid. All the other searches I've done convert the entire sheet to a PDF and email it which isn't what I want to do and I couldn't find what parts of those sample codes to delete because it looks like PDFs are recognized as web addresses. Any help would be greatly appreciated.

解决方案

It appears there is no direct way to convert a Range to a PDF (blob) in Google Apps Script. The best you could do is copy the range values to a blank spreadsheet, apply your formatting, then export that sheet.

You could write the PDF to a folder on Google Drive, then use the Drive software on your computer to sync that folder to the one on your desktop accomplish the last part.

I don't have a snippet of code that does this handy, but here are the relevant documentation links:

https://developers.google.com/apps-script/reference/spreadsheet/range#getvalues

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#create(String)

https://developers.google.com/apps-script/reference/spreadsheet/range#setValues(Object)

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getAs(String)

https://developers.google.com/apps-script/reference/drive/drive-app#createFile(String,String,String)

这篇关于在Google Apps脚本中将范围导出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆