Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Move a sheet using EPPlus?

Tags:

c#

epplus

What is the command needed in EPPlus , to move a worksheet location in a workbook?

I couldn't find any Move command for EPPlus only Interop.

like image 975
James Avatar asked Jun 22 '16 14:06

James


2 Answers

There are four methods for moving a worksheet. They are

excelPackage.Workbook.Worksheets.MoveAfter()
excelPackage.Workbook.Worksheets.MoveBefore()
excelPackage.Workbook.Worksheets.MoveToStart()
excelPackage.Workbook.Worksheets.MoveToEnd()
like image 73
chandler Avatar answered Sep 25 '22 02:09

chandler


For anybody finding this in 2021, @chandler is totally correct, but let me add this:

//
// Summary:
//     Moves the source worksheet to the start of the worksheets collection
//
// Parameters:
//   sourceName:
//     The name of the source worksheet
public void MoveToStart(string sourceName);

myExcelPackage.Workbook.Worksheets.MoveToStart(myExcelWorkSheetObject.Name);

The worksheetName input parameter tripped me up.

like image 33
RockiesMagicNumber Avatar answered Sep 26 '22 02:09

RockiesMagicNumber