is anyone here who can help improve my script? I want the results to be more visually presentable. Is is possible to include in HTML code?
function showAEdata() {
var ui = SpreadsheetApp.getUi();
var input = ui.prompt("Please enter your First Name and Last Name.", ui.ButtonSet.OK_CANCEL);
if (input.getSelectedButton() == ui.Button.OK) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ws = ss.getSheetByName("Monitoring (Database)");
var data = ws.getRange("A2:X" + ws.getLastRow()).getValues();
var userSelectedRep = input.getResponseText().toLowerCase();
var newData = data.filter(function (r) {
return r[6].toLowerCase() == userSelectedRep;
});
var yearInput = ui.prompt("Please enter the year (e.g., 2024):", ui.ButtonSet.OK_CANCEL);
if (yearInput.getSelectedButton() == ui.Button.OK) {
var selectedYear = yearInput.getResponseText();
var filteredYearData = newData.filter(function (r) {
var date = new Date(r[5]);
return date.getFullYear() == selectedYear;
});
var selectedColumns = filteredYearData.map(function (r) {
return [r[1], r[2], r[4], r[5], r[9], r[10], r[11], r[17]];
});
if (filteredYearData.length > 0) {
var newWs = ss.insertSheet(userSelectedRep);
var headers = ["INSTITUTION", "MONTH", "JO NUMBER", "DATE RELEASED", "TYPE OF USER", "PLATFORM", "TYPE OF ACCESS", "NUMBER OF ACCESS CODE"];
newWs.getRange(4, 3, selectedColumns.length, selectedColumns[0].length).setValues(selectedColumns);
newWs.getRange(3, 3, 1, headers.length).setValues([headers]);
} else {
ui.alert("No matching data found for the entered year.");
}
} else {
ui.alert("Year input canceled.");
}
} else {
ui.alert("Operation Canceled.");
}
}
This the current result of my Script I want to enhance it by using HTML etc.