Files
ClosedXML/ClosedXML_Examples/Misc/MultipleSheets.cs
T
Thom Lamb 2cd6df6481 Initial commit of the ClosedXML library
Establishes the foundational structure, core Excel functionality, and tooling.

- Implements base components for cells, ranges, columns, and rows.
- Integrates a custom calculation engine with a wide range of Excel functions.
- Adds comprehensive support for styling, conditional formatting, data validation, comments, pictures, and charts.
- Configures build setup, project metadata (NuGet), and developer guidelines.
- Includes editor and Git attributes for consistent code style and line endings.
2026-06-23 11:02:53 -05:00

31 lines
794 B
C#

using System.Linq;
using ClosedXML.Excel;
namespace ClosedXML_Examples.Misc
{
public class MultipleSheets : IXLExample
{
public void Create(string filePath)
{
var wb = new XLWorkbook();
foreach (var wsNum in Enumerable.Range(1, 5))
{
wb.Worksheets.Add("Original Pos. is " + wsNum.ToString());
}
// Move first worksheet to the last position
wb.Worksheet(1).Position = wb.Worksheets.Count() + 1;
// Delete worksheet on position 4 (in this case it's where original position = 5)
wb.Worksheet(4).Delete();
// Swap sheets in positions 1 and 2
wb.Worksheet(2).Position = 1;
wb.SaveAs(filePath);
}
}
}