Add worksheets in XLS documet, Get worksheet using its name, Access data within worksheet using Bytescout Spreadsheet SDK

  • Home
  • /
  • Articles
  • /
  • Add worksheets in XLS documet, Get worksheet using its name, Access data within worksheet using Bytescout Spreadsheet SDK

Add new worksheets into Excel document, access existing worksheets and their data using Bytescout Spreadsheet SDK

This sample provides source code example to show how to add worksheets in XLS Excel document, how to access existing worksheet using worksheet name, how to access cells in worksheet using Bytescout Spreadsheet SDK for .NET

Download example source code: bytescoutxls_working_with_worksheets.zip (5 KB)

Excel document with new worksheets

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.Spreadsheet;
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”;
// Save document
document.SaveAs(“Worksheets.xls”);
}
}
}

Download example source code: bytescoutxls_working_with_worksheets.zip (5 KB)

prev
next