I don't know of a way to do it in Excel. And for sure I don't know a way that would import/export with Numbers.
The closest thing I know of in Excel is the "Group" feature (found in the Data tab of Excel). But this requires you to sort the table, add a new column to the left and a new row for each category name, manually put the category names in the new column, select rows for a particular category, Group, select the rows for the next category, Group, etc. Subcategories would require doing the same thing one level down. All manual processes. There is something called "auto outline" but I can't figure out what it needs to work, it won't auto-anything for me. But if you figure it out, maybe it helps automate the process some (or maybe it does something else entirely).
Rows 1 & 4 and column A are the ones I added for category headings. You use the minus signs on the left to collapse a group. The group for Category 1 is rows 2&3 (not including row 1 or the heading will collapse/hide as well)
Bottom line: A royal pain.