Michael S Michael S - 1 month ago 22
C# Question

C# - Excel API - Determining parent/child relationship between Rows

I am exporting a smartsheet, and in order to maintain the hierarchy of rows, I need to use Excel format (can't use CSV). I'm wondering if IExcelDataReader will support this hierarchy of a row being contained inside of another row. I am not finding any documentation on this.

Answer

I don't see anything in IExcelDataReader that mentions Excel Row Groups. But there is an easier way that won't require you to use Excel sheets at all.

In Smartsheet, you could add another column, and add the formula =COUNT(ANCESTORS()) to each row. This will give you a numerical value you can work with in CSV format. Topmost rows will have a value of 0, children of topmost rows will have 1, and so on. In the logic that manipulates your CSV, you can then determine the hierarchy quite easily.