Set different FontStyles to Cell

Hi,

I would like to set different fontstyles (bold, italic, underline, strikeout) to a single cell, for example to display cell content in bold and italic. It seems FontStyle allows me to set only a single style.

It is possible to do so through the ContextMenuManager clicking on Format Cells, but I would like to control such feature through a toolbar.

Do you have any code to do that?

Thanks, Oliver

Hi Oliver,

Thank you for considering Aspose.

Well, you can set multiple Font Styles for a cell using the Style.Font options. Please see the following Sample code in this regard,

WebWorksheet sheet = GridWeb1.WebWorksheets[0];

sheet.Cells[6, 4].PutValue("Font Setting");

sheet.Cells[6, 4].Style.Font.Bold = true;

sheet.Cells[6, 4].Style.Font.Italic = true;

Please do let us know if you need any further information regarding this issue, we will be happy to help you out.

Thank You & Best Regards,

Hi Oliver,

And, in case, if your are using Aspose.Grid.Desktop, please see the following code.

Sample code:

[VB]

Dim sheet As Aspose.Grid.Desktop.Worksheet = GridDesktop1.Worksheets(0)

Dim cell As Aspose.Grid.Desktop.GridCell = sheet.Cells("E7")

cell.Value = "Font Setting"

Dim font As Font = New System.Drawing.Font("Arial", 12.0F, FontStyle.Bold Or FontStyle.Italic)

cell.SetFont(font)

[C#]

Aspose.Grid.Desktop.Worksheet sheet = GridDesktop1.Worksheets[0];

Aspose.Grid.Desktop.GridCell cell = sheet.Cells["E7"];

cell.Value = "Font Setting";

Font font = new System.Drawing.Font("Arial", 12.0F, FontStyle.Bold | FontStyle.Italic);

cell.SetFont(font);

Thank you.