DEV Community

IronSoftware
IronSoftware

Posted on • Originally published at ironsoftware.com

3 2

Work with Excel WorkSheets

An IronXL.WorkBook represents and entire Excel (XLSX or XLS) file.

An IronXL.WorkSheet represents one page or tab within that file.

C#:

using IronXL;

//This is how we create new worksheet
WorkBook workBook = WorkBook.Load("test.xlsx");

//This is how we create new worksheet
var newSheet = workBook.CreateWorkSheet("new_sheet");
//You can perform any operations you want with the new sheet.
newSheet["B2"].Value = DateTime.Now;


// Work with an existing Worksheets 
WorkSheet oldSheet = workbook.GetWorkSheet("sheet1");
//...

// Work with the first Worksheet
WorkSheet firstSheet = workbook.DefaultWorkSheet;
//...


//Save in Excel format or export to many other file formats
workBook.SaveAs("test.xlsx");
Enter fullscreen mode Exit fullscreen mode

VB:

Imports IronXL

'This is how we create new worksheet
Private workBook As WorkBook = WorkBook.Load("test.xlsx")

'This is how we create new worksheet
Private newSheet = workBook.CreateWorkSheet("new_sheet")
'You can perform any operations you want with the new sheet.
Private newSheet("B2").Value = DateTime.Now


' Work with an existing Worksheets 
Private oldSheet As WorkSheet = workbook.GetWorkSheet("sheet1")
'...

' Work with the first Worksheet
Private firstSheet As WorkSheet = workbook.DefaultWorkSheet
'...


'Save in Excel format or export to many other file formats
workBook.SaveAs("test.xlsx")
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay