Need to add sup tag in excel

Hi,

I am using Aspose.Cells 5.1 version to generate excel. I have the requirement for adding tag in all the columns. ie. In the web page, i can use sup tag. I have no idea how to put tag in excel. Could you please help me. Attached screenshot of that rendered using web page.

Hi,

Please check the document for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/dealing-with-font-settings.html

Here is a sample code for your reference, I will put “1781” with last “1” as superscript.
Sample code:
Workbook excel = new Workbook();
Worksheet worksheet = excel.Worksheets[0];
Cells cells = worksheet.Cells;
cells[0,0].PutValue(“1781”);
cells[0, 0].Characters(3, 1).Font.IsSuperscript = true;
excel.Save(“e:\test2\outsuperscript.xls”);

Hi,

I am having number in that column. So while using your code

cells[0,0].Characters(3, 1).Font.IsSuperscript = true;

I am getting the following error ."This method only works on cell with string value.". Please help me in solving this issue.

Hi,

Yes sure, you will get that exception. The reason is MS Excel would work for superscript for string data, it will not work on numeric values. This is the limitation of MS Excel and not Aspose.Cells by any means. You may confirm it in MS Excel. I think you need to convert the numeric values to strings first then apply the superscript to those cells.
e.g
//Convert the existing numeric data to string data
cells[0,0].PutValue(cells[0,0].StringValue);

cells[0,0].Characters(3, 1).Font.IsSuperscript = true;


Thank you.