 
         
         
             Important Update
                        Important Update
                    
                The sample source codes on this page will demonstrate you how to make fonts available for cells in C#. ByteScout Spreadsheet SDK was made to help with fonts available for cells in C#. ByteScout Spreadsheet SDK is the library (SDK) that is capable of writing, reading, modifying and calculating Excel and CSV spreadsheets. Most popular formulas can be calculated and reculculated with Excel installed. You may import or export data to and from CSV, XML, JSON as well as to and from databases, arrays.
You will save a lot of time on writing and testing code as you may just take the code below and use it in your application. Follow the instruction from the scratch to work and copy and paste code for C# into your editor. Code testing will allow the function to be tested and work properly with your data.
Free trial version of ByteScout Spreadsheet SDK is available on our website. Get it to try other samples for C#.
  On-demand (REST Web API) version: 
   Web API (on-demand version)
  
  On-premise offline SDK for Windows: 
   60 Day Free Trial (on-premise)
      using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Bytescout.Spreadsheet;
using System.IO;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create new Spreadsheet
            Spreadsheet document = new Spreadsheet();
            // 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];
            }
            // delete output file if exists already
            if (File.Exists("Fonts.xls")){
                File.Delete("Fonts.xls");
            }
            // Save document
            document.SaveAs("Fonts.xls");
            
            // Close document
            document.Close();
            // open generated XLS document in default program
            Process.Start("Fonts.xls");
        }
    }
}
    
    60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page
    
    Explore ByteScout Spreadsheet SDK Documentation
    
    Explore Samples
    
    Sign Up for ByteScout Spreadsheet SDK Online Training
    Get Your API Key
    
    Explore Web API Docs
    
    Explore Web API Samples    
60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page
Explore ByteScout Spreadsheet SDK Documentation
Explore Samples
Sign Up for ByteScout Spreadsheet SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: 
