How to rename worksheet in existing spreadsheet using Bytescout Spreadsheet for .NET - ByteScout

How to rename worksheet in existing spreadsheet using Bytescout Spreadsheet for .NET

  • Home
  • /
  • Articles
  • /
  • How to rename worksheet in existing spreadsheet using Bytescout Spreadsheet for .NET

How to rename a worksheet in existing spreadsheet (Excel XLS) using Bytescout Spreadsheet SDK

This source code sample demonstrates how to rename workshett in existing XLS document file using Bytescout Spreadsheet SDK for .NET

Download example source code: bytescoutxls_rename_worksheet.zip (8 KB)

Screenshot of the spreadsheet with renamed worksheet (first worksheet was renamed from “Sheet1” into “Collected Data Sheet”):

Renamed worksheet in existing XLS spreadshett

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

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// Create new Spreadsheet
Spreadsheet document = new Spreadsheet(“Data.xls”);

// Get worksheet by name
Worksheet worksheet = document.Workbook.Worksheets.ByName(“Sheet1”);

// Set new worksheet name
worksheet.Name = “Collected Data Sheet”;

// Save document
document.SaveAs(“RenamedData.xls”);

// Close document
document.Close();

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

Download example source code: bytescoutxls_rename_worksheet.zip (8 KB)

Tutorials:

prev
next