0

我正在使用Google表格创建表单,并且已使用Google Apps脚本为表单创建按钮。我只是在写信来询问为什么每当我使用下面的脚本时,创建PDF的链接都不会显示为链接,只是单词“This”而没有其他内容,没有超链接或任何其他链接。应该使用Google Apps脚本时无超链接

下面是脚本:

function printPdf() { 
    SpreadsheetApp.flush(); 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var sheet = ss.getActiveSheet(); 

    var gid = sheet.getSheetId(); 

    var pdfOpts = '&size=A4&fzr=false&portrait=true&fitw=true&gridlines=false&printtitle=false&sheetnames=false&pagenum=UNDEFINED&attachment=false&gid='+gid; 


    var row2 = 56; 
    var printRange = '&c1=0' + '&r1=0' + '&c2=7' + '&r2='+row2; // B2:APn 
    var url = ss.getUrl().replace(/edit$/, '') + 'export?format=pdf' + pdfOpts + printRange; 

     var app = UiApp.createApplication().setWidth(100).setHeight(25); 
    app.setTitle('Click the link below to open as PDF'); 

    var link = app.createAnchor('Open PDF', url).setTarget('_new'); 

    app.add(link); 

    ss.show(app); 
    } 

This image below shows a screenshot of what I am talking about when I say there's no link to open the PDF.

这工作,当我使用一个谷歌帐户,但每当我使用任何其他帐户,该链接不起作用。我的经理在与他分享之后,也会尝试使用他的Google帐户,但对他也不起作用。该脚本具有所需的所有权威权限,我无法发现一个Google帐户与其他Google帐户之间的权限差异。我甚至尝试将工作表的所有权转移到不起作用的帐户,但仍然没有运气。有什么想法吗?

+0

在工作版本和非工作版本的脚本编辑器中,执行脚本显示(查看>执行脚本)是什么? Uiapp也被弃用。不支持或推荐的谷歌。改为使用Google开发者页面中提到的对话框。 –

回答

0

第一次在新的电子表格上运行脚本时,它会显示适合我的链接。 我会考虑切换到HTML服务,因为用户界面已弃用。 了UiApp API是deprecated.Expand 文件:代码行:15 锚API是deprecated.Expand 文件:代码行:18 UiInstance API是deprecated.Expand 文件:代码行:15

screenshot

+1

我不觉得傻!我刚才正在研究这个问题,并注意到“This”一词下方的文字略带黑色。然后我进入脚本,制作应用程序框的大小为400 x 100而不是100 x 25,并且显示更多文本表示“此应用程序是由其他用户创建的,而不是由Google创建的”。用实际的超链接UNDERNEATH表示文字。好家伙... – KFarley