May 17 2023 06:57 AM
I am currently writing an excel script that populates a table. I am trying to add a hyperlink to one of the columns; however, when I add the hyperlink via a setValue or a setFormula function, the very last setFormula/setValue function auto populates the remaining rows in the table. I have already turned CalculationMode to manual in the code.
May 18 2023 12:52 AM
If you're experiencing issues with formulas auto-updating when using Office Scripts in Excel, there are a few possible reasons and solutions to consider:
By ensuring correct CalculationMode settings, using absolute references, specifying the correct range, and managing row iteration appropriately, you can mitigate issues with formulas auto-updating in Office Scripts. If the problem persists, reviewing the specific code you're using might provide further insights into the issue and potential solutions.
May 18 2023 05:41 AM
May 18 2023 07:55 AM
Thank you for providing more details and sharing the code snippet. Based on the information you provided, it seems for me that the code itself is correct and should set the hyperlinks properly in the specified cells.
Given that you have already verified the other aspects mentioned, such as calculation mode and range, there might be a few additional things to consider:
table.getRange().getCell(i + 1, 3).setValue("https://help.examplesite.com/tickets/" + jsonData[0][0][i]['ticket_id']).setHyperlink(true);
This approach sets the cell value directly as the URL and applies the hyperlink format to it.
May 18 2023 10:04 AM
May 18 2023 10:05 AM
May 18 2023 03:49 PM
@charles983 here's the documentation for the setHyperlink method: ExcelScript.Range interface - Office Scripts | Microsoft Learn
You can try using it like this:
table.getRange().getCell(i + 1, 3).setHyperlink({ address: "https://help.examplesite.com/tickets/" + jsonData[0][0][i]['ticket_id'] })
Let me know if that helps or if you have any questions!
May 19 2023 01:34 AM
table.getRange().getCell(i + 1, 3).setFormula('=HYPERLINK("https://help.examplesite.com/tickets/' + jsonData[0][0][i]['ticket_id'] + '")');
I'm not so sure, but try this code if other options don't work.
May 19 2023 05:37 AM
May 19 2023 05:43 AM
May 19 2023 12:13 PM
Solution@charles983 Glad to hear that worked! You can specify the text to display like this:
table.getRange().getCell(i + 1, 3).setHyperlink({
address: "https://help.examplesite.com/tickets/" + jsonData[0][0][i]['ticket_id'],
textToDisplay: "text here"
})
Using multiple lines isn't necessary but it does help make the code more readable.
May 19 2023 12:16 PM
May 19 2023 12:13 PM
Solution@charles983 Glad to hear that worked! You can specify the text to display like this:
table.getRange().getCell(i + 1, 3).setHyperlink({
address: "https://help.examplesite.com/tickets/" + jsonData[0][0][i]['ticket_id'],
textToDisplay: "text here"
})
Using multiple lines isn't necessary but it does help make the code more readable.