Free Support Forum - aspose.com

Is there any way to read the superscript in excel


#1

Hi
I want to read the super script fro the created excel sheet and apply the bracket around the text is this possible using the ASPOSE


#2

@Shree995,

Thanks for your query.

See the following sample code segment on how to retrieve superscript text in the cell for your reference. I used a simple template file containing a few cells where A1 cell has superscript text with normal text. The sample code is in .NET, so you may easily convert it to Java by yourselves (if required):
e.g
Sample code:

string filePath = "e:\\test2\\Bk_superscript1.xlsx";
            Workbook workbook = new Workbook(filePath);
            Worksheet worksheet = workbook.Worksheets[0];

            Cell cell = worksheet.Cells["A1"];
            FontSetting[] fntSettings = cell.GetCharacters();

                if (fntSettings != null)
                {

                    foreach (FontSetting fnt in fntSettings)
                    {

                        if (fnt.Font.IsSuperscript == true)
                        {

                            string supText = cell.StringValue.Substring(fnt.StartIndex, fnt.Length);
                            Debug.WriteLine("[Cell Name]: " + cell.Name + " [SuperScript Text]: " + supText);

                        }//if

                    }//foreach

                }//if

Also, to add specific characters (around superscript text) you may write your own code and logic by yourselves to accomplish the task.