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

Free Support Forum - aspose.com

Symbol in table cell

How can I insert symbols (ex. left and right arrows), shapes (diamond, triangle) found in Windings, Windings2 and Windings3 font type into table cells?

Dear Patrick,

Thanks for considering Aspose.Slides.

To add symbols, you must know their (hex or decimal) codes and their fonts. You can find them out by creating such symbols in some presentation using MS-PowerPoint and then inspecting their values in debugger with the help of Aspose.Slides.

Below is the sample code that inserts 4 such symbols, it is fully commented for your help and I have also attached its output.

//Create an empty presentation

Presentation pres = new Presentation();

//Get the empty slide

Slide sld = pres.GetSlideByPosition(1);

//Add a rectangle shape and textframe

Table tbl = sld.Shapes.AddTable(100, 100, 4000,2000,3,3);

//Get the textframe

TextFrame tf = tbl.GetCell(1, 1).TextFrame;

//Add Font and note its index

//You will have to add symbol charset wingdings font

FontEntity rawSymbolFontEnt = new FontEntity(pres, pres.Fonts[0]);

rawSymbolFontEnt.CharSet = FontCharSet.SYMBOL_CHARSET;

rawSymbolFontEnt.FontName = "Wingdings";

int rawSymbolFontIndex = pres.Fonts.Add(rawSymbolFontEnt);

//Add symbol characters from their hex codes

StringBuilder sb = new StringBuilder();





//Write the text in the portion

Portion port=tf.Paragraphs[0].Portions[0];

port.Text = sb.ToString();

//Set the RawSymbolFontIndex property

port.RawSymbolFontIndex = rawSymbolFontIndex;

//Write presentation on disk


Thanks Shakeel! Your sample code is helpful. How can I add a space and some text (with a font type of Arial) after the symbol in the table cell?

You can add a new portion and add it in your paragraph. Here is the code example. Insert them just before writing the presentation on disk in my above code.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

//Add a portion with space and some more text

Portion <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />newPort = new Portion(port);

newPort.Text = " some arial text.";

//Assume Presentation.Fonts[0] has arial

newPort.FontIndex = 0;

//Add it in paragraph's portions collection


Thanks Shakeel! Can you show me how to add $1 to a table cell? I tried setting the escapement property of the portion; but can’t seems to get it right.

In $1, 1 is actually a superscript. You should add this code to insert it.

//Add two more portions for $1

Portion newPort1 = new Portion(port);

newPort1.Text = "$";


Portion newPort2 = new Portion(newPort1);

newPort2.Text = "1";

newPort2.Escapement = 30; //To make the 1 superscript