I have a spreadsheet that has multiple cells containing XML formatting that I want to remove. The problem is that I can't just remove a linebreak since it ruins the formatting of the text. How can I replace the <br />
with a linebreak?
function run() {
return Excel.run(function(context) {
const sheet1 = context.workbook.worksheets.getItem("Sheet1");
const sheet2 = context.workbook.worksheets.getItem("Sheet2");
const sourceCell = sheet1.getCell(1,1).load("text")
const destinationCell = sheet2.getCell(1,1)
return context.sync().then(function() {
destinationCell.values = sourceCell.text
})
})
}
Let's say my sourceCell contains the following text:
[["08:00 - 08:30 brushing teeth<br />08:30 - 09:00 eating breakfast<br />09:00 - 09:30 ride the bus"]]
How would I go about replacing the <br />
with a linebreak in the destination cell?