Delete Multiple Ranges in Online Excel Typescript

Viewed 23

Suppose you have a simple sheet, and you'd like to delete more than one column (or range) of cells in one go. For example, delete columns and shift left for columns A:C,F,I:K. The solution I found was multiple select ranges

    let The_Sheet = workbook.getWorksheet("The_Sheet");
    The_Sheet.getRange("A:C").delete(ExcelScript.DeleteShiftDirection.left);
    The_Sheet.getRange("F:F").delete(ExcelScript.DeleteShiftDirection.left);
    The_Sheet.getRange("I:K").delete(ExcelScript.DeleteShiftDirection.left);

But surely there is a neater solution? I suppose you could store the strings in an array and loop through these, but what do you think?

Other thoughts: The .getRanges method returns a RangeAreas object, which has no delete method.

Also, this is my first stack overflow question, so any feedback about the question or formatting is also much appreciated. :)

0 Answers
Related