You can get the superscript/subscript information from Excel via the logical flags in the Font Property
of the given Range
:
Range curRange = ws.get_Range("A1");
if(curRange.Font.Superscript)
{
//It is a superscript
}
if(curRange.Font.Subscript)
{
//It is a subscript
}
The easiest way to represent this in C# winforms is relying on a RichTextBox
(you can even make it "look like a label", as suggested in the following link) and on its SelectionCharOffset
. With Labels
, it is not so straightforward but there are some workarounds.
---------- UPDATE
ANSWER TO THE FIRST QUESTION:
C# supports formatting through its Objects
, not its string type
. Excel strings
do not support formatting either; the Ranges
are the ones in charge of dealing with this.
ANSWER TO THE SECOND QUESTION:
You can replicate in C# what Excel Cells
/Ranges
do by relying on the corresponding C# equivalent, that is: Controls
/Objects
. The Control
meant for text-decoration is the RichTextBox
and thus it is the best equivalent in this case. Nonetheless, there are different ways to deliver the result you want by using other Controls
, as explained above.