HelloWorldCS

 
using System;

using GemBox.Spreadsheet;

namespace Samples
{
    /// <summary>
    /// HelloWorld sample.
    /// </summary>
    class HelloWorldCS
    {
        [STAThread]
        static void Main(string[] args)
        {
            // TODO: If using GemBox.Spreadsheet Professional, put your serial key below.
            // Otherwise, if you are using GemBox.Spreadsheet Free, comment out the 
            // following line (Free version doesn't have SetLicense method). 
            // SpreadsheetInfo.SetLicense("YOUR-SERIAL-KEY-HERE");

            ExcelFile excelFile = new ExcelFile();

            ExcelWorksheet ws = excelFile.Worksheets.Add("HelloWorldCS");

            ws.Cells[0, 0].Value = "English:";
            ws.Cells[0, 1].Value = "Hello";

            ws.Cells[1, 0].Value = "Russian:";
            // Using UNICODE string.
            ws.Cells[1, 1].Value = new string(new char[] { '\u0417', '\u0434', '\u0440', '\u0430', '\u0432', '\u0441', '\u0442', '\u0432', '\u0443', '\u0439', '\u0442', '\u0435' });

            ws.Cells[2, 0].Value = "Chinese:";
            // Using UNICODE string.
            ws.Cells[2, 1].Value = new string(new char[] { '\u4f60', '\u597d' });

            ws.Cells["A5"].Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your machine.";

            string fileName = "HelloWorldCS.xls";
            excelFile.SaveXls(fileName);
            // Uncomment if you want to export in XLSX.
            //string fileName = "HelloWorldCS.xlsx";
            //excelFile.SaveXlsx(fileName);

            TryToDisplayGeneratedFile(fileName);
        }

        static void TryToDisplayGeneratedFile(string fileName)
        {
            try
            {
                System.Diagnostics.Process.Start(fileName);
            }
            catch (Exception)
            {
                Console.WriteLine(fileName + " created in application folder.");
            }
        }
    }
}

 

ASP NET Spreadsheet Component For Reading/Writing XLS/CSV/HTML/XLSX Files