Hello World

GemBox.Spreadsheet is a .NET component which provides an easy and high performance way to write, read, convert and print spreadsheet files (XLSX, XLS, CSV, ODS, HTML, PDF, XPS) without the need for Microsoft Excel on either the developer or client machines.

Screenshot

Hello World Screenshot

Following sample creates simple HelloWorld file using our component. It shows how to initialize our object model, populate some cells, and then save it to a file in the desired format. It also demonstrates support for International characters (Unicode support).

Notice that below you have Run options where you can choose output file format.

See the full code below, use RUN EXAMPLE to execute.


1using GemBox.Spreadsheet;
2
3class Sample
4{
5    [STAThread]
6    static void Main(string[] args)
7    {
8        // If using Professional version, put your serial key below.
9        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
10
11        ExcelFile ef = new ExcelFile();
12        ExcelWorksheet ws = ef.Worksheets.Add("Hello World");
13
14        ws.Cells[0, 0].Value = "English:";
15        ws.Cells[0, 1].Value = "Hello";
16
17        ws.Cells[1, 0].Value = "Russian:";
18        // Using UNICODE string.
19        ws.Cells[1, 1].Value = new string(new char[] { '\u0417', '\u0434', '\u0440', '\u0430', '\u0432', '\u0441', '\u0442', '\u0432', '\u0443', '\u0439', '\u0442', '\u0435' });
20
21        ws.Cells[2, 0].Value = "Chinese:";
22        // Using UNICODE string.
23        ws.Cells[2, 1].Value = new string(new char[] { '\u4f60', '\u597d' });
24
25        ws.Cells[4, 0].Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC.";
26        ws.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = true;
27
28        ef.Save("Hello World.xls");
29    }
30}
1Imports GemBox.Spreadsheet
2
3Module Samples
4
5    Sub Main()
6
7        ' If using Professional version, put your serial key below.
8        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
9
10        Dim ef As ExcelFile = New ExcelFile
11        Dim ws As ExcelWorksheet = ef.Worksheets.Add("Hello World")
12
13        ws.Cells(0, 0).Value = "English:"
14        ws.Cells(0, 1).Value = "Hello"
15
16        ws.Cells(1, 0).Value = "Russian:"
17        ' Using UNICODE string.
18        ws.Cells(1, 1).Value = New String(New Char() {ChrW(&H417), ChrW(&H434), ChrW(&H440), ChrW(&H430), ChrW(&H432), ChrW(&H441), ChrW(&H442), ChrW(&H432), ChrW(&H443), ChrW(&H439), ChrW(&H442), ChrW(&H435)})
19
20        ws.Cells(2, 0).Value = "Chinese:"
21        ' Using UNICODE string.
22        ws.Cells(2, 1).Value = New String(New Char() {ChrW(&H4F60), ChrW(&H597D)})
23
24        ws.Cells(4, 0).Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC."
25        ws.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = True
26
27        ef.Save("Hello World.xls")
28
29    End Sub
30
31End Module

Check next sample or find out more about GemBox.Spreadsheet and GemBox Software.