Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/EPPlus/Core/Worksheet/ExcelTableCopyEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*************************************************************************************************
Required Notice: Copyright (C) EPPlus Software AB.
This software is licensed under PolyForm Noncommercial License 1.0.0
and may only be used for noncommercial purposes
https://polyformproject.org/licenses/noncommercial/1.0.0/

A commercial license to use this software can be purchased at https://epplussoftware.com
*************************************************************************************************
Date Author Change
*************************************************************************************************
08/05/2026 EPPlus Software AB Added
*************************************************************************************************/
namespace OfficeOpenXml.Core.Worksheet
{
/// <summary>
/// Provides context for a table that is being copied to a new worksheet, and allows
/// a custom name to be assigned to the copied table.
/// </summary>
public class ExcelTableCopyEventArgs
{
/// <summary>
/// The name of the table on the source worksheet.
/// </summary>
public string SourceTableName { get; internal set; }

/// <summary>
/// The name that was assigned to the copied table by default, before this handler
/// runs. When the worksheet is copied within the same workbook, this is a generated
/// name (Table1, Table2, ...). When copied to another workbook, the original name is
/// kept when it is still available, in which case this equals <see cref="SourceTableName"/>;
/// if a table with that name already exists in the target workbook, a generated name
/// is used instead.
/// </summary>
public string DefaultName { get; internal set; }

/// <summary>
/// The name to assign to the copied table. Leave as null to keep <see cref="DefaultName"/>.
/// Setting this to an existing table name will cause the same validation exception
/// as a normal table name assignment.
/// </summary>
public string NewName { get; set; }
}
}
35 changes: 35 additions & 0 deletions src/EPPlus/Core/Worksheet/ExcelWorksheetCopyOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*************************************************************************************************
Required Notice: Copyright (C) EPPlus Software AB.
This software is licensed under PolyForm Noncommercial License 1.0.0
and may only be used for noncommercial purposes
https://polyformproject.org/licenses/noncommercial/1.0.0/

A commercial license to use this software can be purchased at https://epplussoftware.com
*************************************************************************************************
Date Author Change
*************************************************************************************************
08/05/2026 EPPlus Software AB Added
*************************************************************************************************/
using System;

namespace OfficeOpenXml.Core.Worksheet
{
/// <summary>
/// Used to specify options when copying a worksheet.
/// </summary>
public class ExcelWorksheetCopyOptions
{
internal static ExcelWorksheetCopyOptions Default => new ExcelWorksheetCopyOptions();

/// <summary>
/// A handler that is invoked for each table that is copied to the new worksheet.
/// Use this to assign a custom name to the copied table. When a worksheet is copied
/// within the same workbook, copied tables are otherwise given a generated name
/// (Table1, Table2, ...). Set <see cref="ExcelTableCopyEventArgs.NewName"/> on the
/// argument to rename the copied table. The rename is applied through the same path
/// as a normal <see cref="OfficeOpenXml.Table.ExcelTable.Name"/> assignment, so
/// formula references are updated and name uniqueness is validated.
/// </summary>
public Action<ExcelTableCopyEventArgs> TableCopyHandler { get; set; }
}
}
Loading
Loading