Link Search Menu Expand Document

Create Worksheets - C#

Spreadsheet SDK sample in C# demonstrating ‘Create Worksheets’

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.Spreadsheet;
using System.IO;
using System.Diagnostics;

namespace Worksheets
    class Program
        static void Main(string[] args)
            // Create new Spreadsheet
            Spreadsheet document = new Spreadsheet();

            // Add worksheets
            Worksheet worksheet1 = document.Workbook.Worksheets.Add("Demo worksheet 1");

            Worksheet worksheet2 = document.Workbook.Worksheets.Add("Demo worksheet 2");

            // Get worksheet by name
            Worksheet worksheetByName = document.Workbook.Worksheets.ByName("Demo worksheet 2");

            // Set cell values
            worksheet1.Cell(0, 0).Value = "This is Demo worksheet 1";

            worksheetByName.Cell(0, 0).Value = "This is Demo worksheet 2";

            // delete output file if exists already
            if (File.Exists("Worksheets.xls")){

            // Save document

            // delete output file if exists already
            if (File.Exists("Output.xls")){

            // open generated XLS document in default program

Download Source Code (.zip)

Return to the previous page Explore Spreadsheet SDK