Use this method to clear all of the hierarchy levels you have set in the worksheet.
CALL METHOD spreadsheet->clear_hierarchy EXPORTING no_flush = no_flush IMPORTING error = error retcode = retcode.