How to set active worksheet in the generated spreadsheet (this worksheet will be selected by default when spreadsheet is opened)

This source code sample demonstrates how to use Bytescout Spreadsheet SDK to select default worksheet in spreadsheet (XLS or other format) document

Download example source code: (4 KB)

Saved XLS document screenshot (Worksheet2 tab is selected by default)

Excel XLS document with 2nd worksheet selected by default

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

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

// Add new worksheets
Worksheet worksheet1 = document.Workbook.Worksheets.Add(“Worksheet1”);
Worksheet worksheet2 = document.Workbook.Worksheets.Add(“Worksheet2”);
Worksheet worksheet3 = document.Workbook.Worksheets.Add(“Worksheet3”);

// Activate worksheet2
worksheet2.Active = true;

// Save document

// Close document

// open generated XLS document in default program

Download example source code: (4 KB)