using System.Drawing;
using Spire.Xls;
namespace FontStyle
{
class Program
{
static void Main(string[] args)
{
//Create a new workbook.
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Write text with the font of Arial.
sheet.Range["B1"].Text = "Arial";
sheet.Range["B1"].Style.Font.FontName = "Arial";
//Write text with the font of Large size.
sheet.Range["B2"].Text = "Large size";
sheet.Range["B2"].Style.Font.Size = 20;
//Write text with the font of Bold.
sheet.Range["B3"].Text = "Bold";
sheet.Range["B3"].Style.Font.IsBold = true;
//Write text with the font of Italic.
sheet.Range["B4"].Text = "Italic";
sheet.Range["B4"].Style.Font.IsItalic = true;
//Write text with the font of Superscript.
sheet.Range["B5"].Text = "Superscript";
sheet.Range["B5"].Style.Font.IsSuperscript = true;
//Write text with the font of Colored.
sheet.Range["B6"].Text = "Colored";
sheet.Range["B6"].Style.Font.Color = Color.FromArgb(255, 125, 125);
//Write text with the font of Underline.
sheet.Range["B7"].Text = "Underline";
sheet.Range["B7"].Style.Font.Underline = FontUnderlineType.Single;
//Save the file.
workbook.SaveToFile("Sample.xls");
//Launch the file.
System.Diagnostics.Process.Start("Sample.xls");
}
}
}
The following code shows some basic settings on VB.NET Excel Font style:
[Visual Basic]
Imports Microsoft.VisualBasic
Imports System.Drawing
Imports Spire.Xls
Module Module1
Sub Main()
'Create a new workbook.
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Write text with the font of Arial.
sheet.Range("B1").Text = "Arial"
sheet.Range("B1").Style.Font.FontName = "Arial"
'Write text with the font of Large size.
sheet.Range("B2").Text = "Large size"
sheet.Range("B2").Style.Font.Size = 20
'Write text with the font of Bold.
sheet.Range("B3").Text = "Bold"
sheet.Range("B3").Style.Font.IsBold = True
'Write text with the font of Italic.
sheet.Range("B4").Text = "Italic"
sheet.Range("B4").Style.Font.IsItalic = True
'Write text with the font of Superscript.
sheet.Range("B5").Text = "Superscript"
sheet.Range("B5").Style.Font.IsSuperscript = True
'Write text with the font of Colored.
sheet.Range("B6").Text = "Colored"
sheet.Range("B6").Style.Font.Color = Color.FromArgb(255, 125, 125)
'Write text with the font of Underline.
sheet.Range("B7").Text = "Underline"
sheet.Range("B7").Style.Font.Underline = FontUnderlineType.Single
'Save the file.
workbook.SaveToFile("Sample.xls")
'Launch the file.
System.Diagnostics.Process.Start("Sample.xls")
End Sub
End Module