I have a google script that I'm using in google spreadsheet to export some data from there. Recently they update the spreadsheet and I'm getting this error:
UiApp has been deprecated. Please use HtmlService instead
var app = UiApp.createApplication().setTitle('Export');
Does anyone had this problem, any solution?
Thank you
Starting point:
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('export');
SpreadsheetApp.getUi()
.setWidth(640)
.setHeight(400)
.showModalDialog(html, 'Export');
}
Docs: https://developers.google.com/apps-script/guides/html/
Please start by learning the pretty basics of developing a web application using "vanilla" HTML/JavaScript/CSS. Mozilla Developers Network and freecodecamp.com among many others might be helpful.
Once you know the pretty basics of developing a web application, read HTML Service: Create and Serve HTML. Below is a very simple code for a web app including HTML/JavaScript/CSS.
function doGet(e){
const css = '<style> p { color: blue;} </style>';
const html = '<p>Hello world!</p>';
const js = '<script>document.addEventListener("click",() => alert("Clicked!"))</script>';
return HtmlService.createHtmlOutput(css + html + js)
.setTitle('My first web app')
.addMetaTag('viewport', 'width=device-width, initial-scale=1');
}
Below is the above code adapted to be used to show a simple modal dialog in Google Sheets
function showDialog(e){
const css = '<style> p { color: blue;} </style>';
const html = '<p>Hello world!</p>';
const js = '<script>document.addEventListener("click",() => alert("Clicked!"))</script>';
SpreadsheetApp.getUi().showModalDialog(
HtmlService.createHtmlOutput(css + html + js),
'My first modal dialog'
)
.setWidth(300)
.setHeight(100)
}
If you don't have time or will to learn, consider to use a no-code tool. As you are already using Google Sheets, Google AppSheet might be a good place to start specially if your spreadsheet already has data tables (sheet having column headers on the first row, values below each of them). To create a no-code app from Google Sheets, click on Extensions - AppSheet.
Resources
Related
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With