This shared spreadsheet has a side bar (opened via the custom menu Extensions Menu)
The side bar displays a list of cells within the spreadsheet.
Currently hard coded A1
,A2
, ... (in SideBarTemplate.html
in the script Editor)
Is it possible to make a link to a specific cell ?
The last line displayed in the side bar This is HyperLink test to A1
is an attempt to use an href tag with a link to A1 (href="#gid=1744285851&range=A1"
)
but this is not working.
Side Bar image:
GAS code:
function onOpen(){
addMenu();
}
function addMenu(){
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [
{name: 'ShowSideBar', functionName: 'showSideBar'}
];
spreadsheet.addMenu ('Extensions Menu', menuItems);
}
function showSideBar(){
// Display a sidebar with custom HtmlService content.
var htmlTemplate = HtmlService
.createTemplateFromFile("SideBarTemplate");
htmlOutput = htmlTemplate.evaluate();
htmlOutput.setTitle('Ext. Side Bar');
SpreadsheetApp.getUi().showSidebar(htmlOutput);
}
HTML template:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
.style1 {
color: blue;
}
.style2 {
color: red;
}
</style>
</head>
<body>
<?var cells = ["A1","A2"]
for (var i = 0; i< cells.length;i++){?>
<div class="style1">Cell: <?=cells[i]?> <p class="style2">Required: How to make the blue text to hyper link to cell <?=cells[i]}?>
</p></div>
<a href="#gid=1744285851&range=A1">This is HyperLink test to A1</a>
</body>
</html>