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