Is there a way to find out the total Height in Float value of an Excel worksheet page programatically (After minus the top and bottom margin) in C#? Thanks
If you find that I have not explained my question clear, please leave a comment. I will improve my question.
Of course, the trivial answer is to subtract the sum of the
PageSetupclass’sTopMarginandBottomMarginproperties from the height of the page; you could build a function to look up the height of the page based on the value of thePageSizeproperty.If you’re looking for anything more useful than that, to calculate something based on the data in the worksheet, after looking around a bit in the Excel object model, I’ve come to the conclusion that the answer is “no”.
I suppose you could, in theory, calculate the height of a printed range of cells, using the nominal height of the rows along with the printer dpi setting and the scale factor, but the chance of getting it right seems extremely small (especially if the scale factor is “shrink to fit” or something similar).