We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Dynamic way to determine the Title Row(s) of a Worksheet


I’m trying to use the PageSetup.setPrintTitleRows/Columns :


I know in both the cases the first value example $1, indicates the start row, how could I determine the second value in a dynamic way (hard coded to $5) in the ‘setPrintTitleRows’
I have the scenario where the row titles could be 2 rows in one document and it could be 5 rows in another during conversion. I would like to make sure all the pages in a given sheet (if its on multiple pages) to have the same row title.
Please let me know if there is an API to get the number of rows that make up the title on the first sheet.


Hi Ung,

Thank you for contacting Aspose support.

I am afraid, there isn’t an easy way to determine if title of a specified worksheet spans over more than one row because Aspose.Cells APIs doesn’t provide such means, because the API cannot differentiate between normal and title rows. It’s up to your own custom logic how you achieve this requirement. One solution could be to compare the adjacent cells/rows for style. For instance, title rows normally have similar formatting applied (font size, foreground/background color), you may opt to compare the first cell of each row (or row as a whole) against the next adjacent cell/row to check if they have the same formatting applied. If the test fails, you may set the row as the ending range for the setPrintTitleRows otherwise continue checking the last cell/row processed against the next adjacent cell/row.