Set active worksheet selected by default in generated spreadsheet document written with Bytescout Spreadsheet SDK for .NET - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

Set active worksheet selected by default in generated spreadsheet document written with Bytescout Spreadsheet SDK for .NET

  • Home
  • /
  • Articles
  • /
  • Set active worksheet selected by default in generated spreadsheet document written with Bytescout Spreadsheet SDK for .NET

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: bytescoutxls_select_active_worksheet.zip (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
document.SaveAs(“SelectingActiveWorksheet.xls”);

// Close document
document.Close();

// open generated XLS document in default program
Process.Start(“SelectingActiveWorksheet.xls”);
}
}
}

Download example source code: bytescoutxls_select_active_worksheet.zip (4 KB)

Tutorials:

prev
next