I am trying to write an Office Script that replaces blank cells with "null" text that I can run in Excel Online. The script I have right now is replacing merged cells with "null". I would like to write it so that if a cell is blank and not merged, then "null".
function main(workbook: ExcelScript.Workbook) {
let sheet = workbook.getWorksheet("Sheet1");
let range = sheet.getUsedRange();
range.getValues().forEach((row, rowIndex) => {
row.forEach((cell, colIndex) => {
if(cell === "") {
range.getCell(rowIndex, colIndex).setValue("null");
}
});
});
}
I have tried using getMergedRanges() without success so far.
The end goal is to prepare the file for a PowerQuery. Because PowerQuery doesn't handle merged cells well, I need to identify all of the non-merged cells first.