Home

Bytescout.XLS for .NET
Screenshots

Click to view sample
Click to view sample
Click to view sample
Click to view sample
Click to view sample
Click to view sample
Click to view sample Click to view sample

Bytescout.XLS library for .NET

Download Free Trial Buy Now More Information

How to use different fonts for cells in spreadsheet Excel XLS documents generates with Bytescout.XLS library

This source code sample demonstrates how to set different font names for cells in spreadsheet and Excel documents generated by Bytescout.XLS for .NET

Download example source code: bytescoutxls_different_fonts_for_cells.zip (8 KB)

Sample spreadsheet (XLS document) screenshot:

Times New Roman and other fonts in generated spreadsheet

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Bytescout.XLS;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// Create new XLSDocument
XLSDocument document = new XLSDocument();

// Add new worksheet
Worksheet worksheet = document.WorkBook.Worksheets.Add("HelloWorld");

// Create array with font names
string[] fontNames = new string[] {
"Helvetica",
"Times New Roman",
"Verdana",
"Times New Roman"
};

// Use all fonts in fontsNames array
for (int i = 0; i < fontNames.Length; i++)
{
// Set font size based on loop counter
float fontSize = 10 + i * 3;

//Set cell font type and font size
worksheet.Cell(i, 0).Font = new System.Drawing.Font(fontNames[i], fontSize);

// Set cell value
worksheet.Cell(i, 0).Value = fontNames[i];
}

// Save document
document.SaveAs("Fonts.xls");

// Close document
document.Close();

// open generated XLS document in default program
Process.Start("Fonts.xls");
}
}
}

Download example source code: bytescoutxls_different_fonts_for_cells.zip (8 KB)

Download Free Trial Buy Now More Information

Documentation online: view (separate window)

First steps tutorials:

Advanced Examples:
Products  |  Download  |  Purchase  |  Support  |  Contacts  |  Testimonials |  

ByteScout, 2003-2008. All other company and product names may be trademarks of their respective companies. Privacy Statement