Repository: dotnetcore/BootstrapBlazor
Pull request #6011: feat(TableColumn): add IgnoreWhenExport parameter
Author: login: ArgoZhang
Labels: name: enhancement
description: New feature or request
Created: 2025-05-10T04:04:02Z | Merged: 2025-05-10T04:11:05Z

## Link issues
fixes #6009 

<!--[Please fill in the relevant Issue number after the # above, such as #42]-->
<!--[请在上方 # 后面填写相关 Issue 编号，如 #42]-->

## Summary By Copilot
This pull request introduces a new property, `IgnoreWhenExport`, across multiple classes and interfaces in the `BootstrapBlazor` library. The property determines whether a column should be ignored during export operations. Additionally, related logic and unit tests have been updated to support and validate this new functionality.

### Feature Addition: `IgnoreWhenExport` Property

* **Property Definition**: Added the `IgnoreWhenExport` property to the `ITableColumn` interface and its implementations (`AutoGenerateColumnAttribute`, `InternalTableColumn`, `TableColumn`) to allow columns to be conditionally excluded during export operations. (`src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs` - [[1]](diffhunk://#diff-de1e5f91f3b983538bb363adecf14020fb890fac8390f265596cf129a6f7f0caR318-R322) `src/BootstrapBlazor/Components/Table/ITableColumn.cs` - [[2]](diffhunk://#diff-69c8022eae97877dd3747ee37adfa016600e9381ec90662ef90827f9058920eeR13-R17) `src/BootstrapBlazor/Components/Table/InternalTableColumn.cs` - [[3]](diffhunk://#diff-b108b228bf8018fc8ec2332f1e6c4c704f328bc99fc85ac2eef54990a12dcc63R325-R329) `src/BootstrapBlazor/Components/Table/TableColumn.cs` - [[4]](diffhunk://#diff-e2e76810e2b1ef51ba7b96c9017cc8df6ca8bb5999a32ab8ca5c204d28f2c1ecR54-R59)

* **Helper Method**: Introduced a new helper method, `GetIgnoreExport`, in the `ITableColumnExtensions` class to simplify the evaluation of the `IgnoreWhenExport` property. (`src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs` - [src/BootstrapBlazor/Extensions/ITableColumnExtensions.csR347-R348](diffhunk://#diff-6bf3ad236565623debfb28c7c18a2a21bdd089aa294538b56491d5db7dd5a2f5R347-R348))

### Logic Updates

* **Export Filtering**: Updated the `GetVisibleColumns` method in `Table.razor.Toolbar.cs` to exclude columns marked with `IgnoreWhenExport` during export operations. (`src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs` - [src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.csL473-R473](diffhunk://#diff-ca9e82d70b95de7204b56fbdace327d330eaef6777601f3d897b0e07c8c3eff8L473-R473))

* **Property Copying**: Modified the `CopyValue` method in `ITableColumnExtensions` to include the `IgnoreWhenExport` property when copying column attributes. (`src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs` - [src/BootstrapBlazor/Extensions/ITableColumnExtensions.csR114](diffhunk://#diff-6bf3ad236565623debfb28c7c18a2a21bdd089aa294538b56491d5db7dd5a2f5R114))

### Unit Tests

* **New Tests**: Added unit tests to verify the functionality of the `IgnoreWhenExport` property, including its behavior in column filtering and export scenarios. (`test/UnitTest/Components/TableTest.cs` - [test/UnitTest/Components/TableTest.csR8211-R8241](diffhunk://#diff-3546a7a8520a1cc0576ca6a1077d468561e7b825b061c3d1aac2daae7a62a160R8211-R8241))

* **Updated Tests**: Enhanced existing tests to validate the inclusion of the `IgnoreWhenExport` property in column definitions and its propagation across components. (`test/UnitTest/Attributes/AutoGenerateClassTest.cs` - [[1]](diffhunk://#diff-200e68e74cf6bc49c72a163b5ac59bc70e3c1ac27a2a18e6d78077c7b9cc96ccL74-R75) [[2]](diffhunk://#diff-200e68e74cf6bc49c72a163b5ac59bc70e3c1ac27a2a18e6d78077c7b9cc96ccR109) `test/UnitTest/Components/InternalTableColumnTest.cs` - [[3]](diffhunk://#diff-551789bcb9425522dabea0225b753680445ba6504d95752d91a439152b47c2a9R89) `test/UnitTest/Utils/UtilityTest.cs` - [[4]](diffhunk://#diff-0dbe587780570b3bfee592d66a7c4af9c483c65e0faaba84ac3552072ad5f96fL584-R590)

## Regression?
- [ ] Yes
- [ ] No

<!--[If yes, specify the version the behavior has regressed from]-->
<!--[是否影响老版本]-->

## Risk
- [ ] High
- [ ] Medium
- [ ] Low

<!--[Justify the selection above]-->

## Verification
- [ ] Manual (required)
- [ ] Automated

## Packaging changes reviewed?
- [ ] Yes
- [ ] No
- [ ] N/A

## ☑️ Self Check before Merge
⚠️ Please check all items below before review. ⚠️
- [ ] Doc is updated/provided or not needed
- [ ] Demo is updated/provided or not needed
- [ ] Merge the latest code from the main branch

## Summary by Sourcery

Add a new `IgnoreWhenExport` property to table columns to allow selective exclusion of columns during export operations

New Features:
- Introduced `IgnoreWhenExport` property for table columns to control column visibility during export

Enhancements:
- Updated export filtering logic to respect the new `IgnoreWhenExport` property
- Extended column attribute copying to include the new property

Tests:
- Added unit tests to verify the `IgnoreWhenExport` functionality in table column filtering and export scenarios

Linked issue #6009: feat(TableColumn): add IgnoreWhenExport parameter

### Discussed in https://github.com/dotnetcore/BootstrapBlazor/discussions/5991

<div type='discussions-op-text'>

<sup>Originally posted by **gudufy** May  8, 2025</sup>
有些自定义模板的列导出的时候是空值，希望能增加该属性用以忽略该列的导出。</div>
Linked issue comments: user: login: bb-auto[bot]
created_at: 2025-05-10T01:04:02Z
body: @ArgoZhang Thank you for contacting us. We will give feedback later.
author_association: NONE

Diff:
diff --git a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs
index e8a5e8b216d..6e8ff39beca 100644
--- a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs
+++ b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs
@@ -315,4 +315,9 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
     /// <inheritdoc/>
     /// </summary>
     public bool IsMarkupString { get; set; }
+
+    /// <summary>
+    /// <inheritdoc/>
+    /// </summary>
+    public bool? IgnoreWhenExport { get; set; }
 }
diff --git a/src/BootstrapBlazor/Components/Table/ITableColumn.cs b/src/BootstrapBlazor/Components/Table/ITableColumn.cs
index a91528f52fd..ac004056c6b 100644
--- a/src/BootstrapBlazor/Components/Table/ITableColumn.cs
+++ b/src/BootstrapBlazor/Components/Table/ITableColumn.cs
@@ -10,6 +10,11 @@ namespace BootstrapBlazor.Components;
 /// </summary>
 public interface ITableColumn : IEditorItem
 {
+    /// <summary>
+    /// Gets or sets whether the current item is ignored when export operation. Default is false.
+    /// </summary>
+    bool? IgnoreWhenExport { get; set; }
+
     /// <summary>
     /// Gets or sets whether sorting is allowed. Default is null.
     /// </summary>
diff --git a/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs b/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs
index 12586f2e719..59a7d6de30c 100644
--- a/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs
+++ b/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs
@@ -322,4 +322,9 @@ class InternalTableColumn(string fieldName, Type fieldType, string? fieldText =
     /// <inheritdoc/>
     /// </summary>
     public Func<ITableColumn, string?, SearchFilterAction>? CustomSearch { get; set; }
+
+    /// <summary>
+    /// <inheritdoc/>
+    /// </summary>
+    public bool? IgnoreWhenExport { get; set; }
 }
diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs
index 968f51cbd38..dca4728d55b 100644
--- a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs
+++ b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs
@@ -470,7 +470,7 @@ public IEnumerable<ITableColumn> GetVisibleColumns()
     {
         // 不可见列
         var items = VisibleColumns.Where(i => i.Visible);
-        return Columns.Where(i => !i.GetIgnore() && items.Any(v => v.Name == i.GetFieldName()) && ScreenSize >= i.ShownWithBreakPoint);
+        return Columns.Where(i => !i.GetIgnoreExport() && !i.GetIgnore() && items.Any(v => v.Name == i.GetFieldName()) && ScreenSize >= i.ShownWithBreakPoint);
     }
 
     private bool GetColumnsListState(ColumnVisibleItem item) => VisibleColumns.Find(i => i.Name == item.Name) is { Visible: true } && VisibleColumns.Where(i => i.Visible).DistinctBy(i => i.Name).Count(i => i.Visible) == 1;
diff --git a/src/BootstrapBlazor/Components/Table/TableColumn.cs b/src/BootstrapBlazor/Components/Table/TableColumn.cs
index 91f9695ed10..af50f4ecf0a 100644
--- a/src/BootstrapBlazor/Components/Table/TableColumn.cs
+++ b/src/BootstrapBlazor/Components/Table/TableColumn.cs
@@ -51,6 +51,12 @@ public class TableColumn<TItem, TType> : BootstrapComponentBase, ITableColumn
     [Parameter]
     public Expression<Func<TType>>? FieldExpression { get; set; }
 
+    /// <summary>
+    /// <inheritdoc/>
+    /// </summary>
+    [Parameter]
+    public bool? IgnoreWhenExport { get; set; }
+
     /// <summary>
     /// <inheritdoc/>
     /// </summary>
diff --git a/src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs b/src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs
index e10c6aaa341..86631ffefb2 100644
--- a/src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs
+++ b/src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs
@@ -111,6 +111,7 @@ private static void CopyValue(this ITableColumn col, ITableColumn dest)
         if (col.ToolboxTemplate != null) dest.ToolboxTemplate = col.ToolboxTemplate;
         if (col.IsRequiredWhenAdd.HasValue) dest.IsRequiredWhenAdd = col.IsRequiredWhenAdd;
         if (col.IsRequiredWhenEdit.HasValue) dest.IsRequiredWhenEdit = col.IsRequiredWhenEdit;
+        if (col.IgnoreWhenExport.HasValue) dest.IgnoreWhenExport = col.IgnoreWhenExport;
     }
 
     /// <summary>
@@ -343,6 +344,8 @@ private static RenderFragment RenderContent(this ITableColumn col, string? text)
 
     internal static bool GetVisible(this ITableColumn col) => col.Visible ?? true;
 
+    internal static bool GetIgnoreExport(this ITableColumn col) => col.IgnoreWhenExport ?? false;
+
     internal static bool GetShowCopyColumn(this ITableColumn col) => col.ShowCopyColumn ?? false;
 
     internal static bool GetShowTips(this ITableColumn col) => col.ShowTips ?? false;
diff --git a/test/UnitTest/Attributes/AutoGenerateClassTest.cs b/test/UnitTest/Attributes/AutoGenerateClassTest.cs
index 575853f3252..fd005c21d55 100644
--- a/test/UnitTest/Attributes/AutoGenerateClassTest.cs
+++ b/test/UnitTest/Attributes/AutoGenerateClassTest.cs
@@ -71,7 +71,8 @@ public void AutoGenerateColumn_Ok()
             HeaderTextWrap = true,
             IsMarkupString = true,
 
-            RequiredErrorMessage = "test"
+            RequiredErrorMessage = "test",
+            IgnoreWhenExport = true
         };
         Assert.Equal(1, attr.Order);
         Assert.True(attr.Ignore);
@@ -105,6 +106,7 @@ public void AutoGenerateColumn_Ok()
         Assert.True(attr.HeaderTextEllipsis);
         Assert.Equal("test header tooltip", attr.HeaderTextTooltip);
         Assert.True(attr.IsMarkupString);
+        Assert.True(attr.IgnoreWhenExport);
 
         var attrInterface = (ITableColumn)attr;
         attrInterface.ShowLabelTooltip = true;
diff --git a/test/UnitTest/Components/InternalTableColumnTest.cs b/test/UnitTest/Components/InternalTableColumnTest.cs
index 87a0af94e69..116bf2c17d0 100644
--- a/test/UnitTest/Components/InternalTableColumnTest.cs
+++ b/test/UnitTest/Components/InternalTableColumnTest.cs
@@ -86,6 +86,7 @@ public void InternalTableColumn_Ok()
         SetValue("IsRequiredWhenAdd", true);
         SetValue("IsRequiredWhenEdit", true);
         SetValue("LookupService", null);
+        SetValue("IgnoreWhenExport", true);
 
         void SetValue(string propertyName, object? val) => type!.GetProperty(propertyName)!.SetValue(instance, val);
     }
diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs
index 15020509840..17e862a42bd 100644
--- a/test/UnitTest/Components/TableTest.cs
+++ b/test/UnitTest/Components/TableTest.cs
@@ -8208,6 +8208,37 @@ public void IsMarkupString_Ok()
         Assert.Equal("<div class=\"table-cell\">&lt;div&gt;Address - Test&lt;/div&gt;</div>", cells[1].InnerHtml);
     }
 
+    [Fact]
+    public void IgnoreWhenExport_Ok()
+    {
+        var items = new Foo[] { new() { Name = "Name", Address = "Address" } };
+        var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
+        {
+            pb.AddChildContent<Table<Foo>>(pb =>
+            {
+                pb.Add(a => a.RenderMode, TableRenderMode.Table);
+                pb.Add(a => a.Items, items);
+                pb.Add(a => a.TableColumns, foo => builder =>
+                {
+                    builder.OpenComponent<TableColumn<Foo, string>>(0);
+                    builder.AddAttribute(1, "Field", "Name");
+                    builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
+                    builder.CloseComponent();
+
+                    builder.OpenComponent<TableColumn<Foo, string>>(0);
+                    builder.AddAttribute(1, "Field", "Address");
+                    builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Address", typeof(string)));
+                    builder.AddAttribute(3, "IgnoreWhenExport", true);
+                    builder.CloseComponent();
+                });
+            });
+        });
+
+        var table = cut.FindComponent<Table<Foo>>();
+        var columns = table.Instance.GetVisibleColumns();
+        Assert.Single(columns);
+    }
+
     [Fact]
     public void OnSelectedRows_Ok()
     {
diff --git a/test/UnitTest/Utils/UtilityTest.cs b/test/UnitTest/Utils/UtilityTest.cs
index bb3340527e6..dd9a83a7ef9 100644
--- a/test/UnitTest/Utils/UtilityTest.cs
+++ b/test/UnitTest/Utils/UtilityTest.cs
@@ -581,12 +581,13 @@ public void GenerateTableColumns_Ok()
     {
         var cols = Utility.GetTableColumns<Cat>(new InternalTableColumn[]
         {
-            new(nameof(Cat.Name), typeof(string)) { Text = "test-Name", LookupServiceData = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false }
+            new(nameof(Cat.Name), typeof(string)) { Text = "test-Name", LookupServiceData = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false, IgnoreWhenExport = true }
         });
         Assert.Equal(2, cols.Count());
         Assert.Equal(true, cols.First().LookupServiceData);
         Assert.False(cols.First().IsVisibleWhenAdd);
         Assert.False(cols.First().IsVisibleWhenEdit);
+        Assert.True(cols.First().IgnoreWhenExport);
     }
 
     [Fact]


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR introduces the new IgnoreWhenExport property to the table column implementations in the BootstrapBlazor library so that columns can be conditionally excluded during export operations. The key changes include:
- Adding the IgnoreWhenExport property to interfaces and classes (ITableColumn, TableColumn, InternalTableColumn, AutoGenerateColumnAttribute).
- Updating the helper methods and copy logic to support the new property.
- Adding and updating unit tests to verify the new export filtering behavior.

### Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

<details>
<summary>Show a summary per file</summary>

| File | Description |
| ---- | ----------- |
| test/UnitTest/Utils/UtilityTest.cs | Updated tests to verify IgnoreWhenExport on generated table columns |
| test/UnitTest/Components/TableTest.cs | Added unit tests to assert export filtering of columns via IgnoreWhenExport |
| test/UnitTest/Components/InternalTableColumnTest.cs | Extended property assignments with IgnoreWhenExport |
| test/UnitTest/Attributes/AutoGenerateClassTest.cs | Updated tests for AutoGenerateColumn attribute ensuring IgnoreWhenExport propagates |
| src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs | Added support for IgnoreWhenExport in CopyValue and added GetIgnoreExport helper |
| src/BootstrapBlazor/Components/Table/TableColumn.cs | Introduced new parameter IgnoreWhenExport |
| src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs | Updated visible columns filtering to account for IgnoreWhenExport |
| src/BootstrapBlazor/Components/Table/InternalTableColumn.cs | Added the IgnoreWhenExport property |
| src/BootstrapBlazor/Components/Table/ITableColumn.cs | Extended the interface with IgnoreWhenExport property |
| src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs | Added the IgnoreWhenExport property to the attribute |
</details>





state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-10T04:04:15Z
user: login: sourcery-ai[bot]
body: Hey @ArgoZhang - I've reviewed your changes and they look great!

<details>
<summary>Here's what I looked at during the review</summary>

- 🟢 **General issues**: all looks good
- 🟢 **Security**: all looks good
- 🟡 **Testing**: 2 issues found
- 🟢 **Complexity**: all looks good
- 🟢 **Documentation**: all looks good
</details>

***

<details>
<summary>Sourcery is free for open source - if you like our reviews please consider sharing them ✨</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https://sourcery.ai)
- [Facebook](https://www.facebook.com/sharer/sharer.php?u=https://sourcery.ai)

</details>

<sub>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
</sub>
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-10T04:07:19Z

Review comments:
diff_hunk: @@ -8208,6 +8208,37 @@ public void IsMarkupString_Ok()
         Assert.Equal("<div class=\"table-cell\">&lt;div&gt;Address - Test&lt;/div&gt;</div>", cells[1].InnerHtml);
     }
 
+    [Fact]
+    public void IgnoreWhenExport_Ok()
path: test/UnitTest/Components/TableTest.cs
user: login: sourcery-ai[bot]
body: **suggestion (testing):** Enhance `IgnoreWhenExport` testing with more varied scenarios.

Add tests for:
- `IgnoreWhenExport = false` (should be included)
- All columns with `IgnoreWhenExport = true` (should yield empty)
- Multiple columns with no ignored flags (all should be included)

Suggested implementation:

```csharp
    [Fact]
    public void IgnoreWhenExport_Ok()
    {
        // Original test method may be left intact (if needed) or removed.
        // For demonstration, we keep the original scenario unchanged.
        var items = new Foo[] { new() { Name = "Name", Address = "Address" } };
        var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
        {
            pb.AddChildContent<Table<Foo>>(pb =>
            {
                pb.Add(a => a.RenderMode, TableRenderMode.Table);
                pb.Add(a => a.Items, items);
                pb.Add(a => a.TableColumns, foo => builder =>
                {
                    builder.OpenComponent<TableColumn<Foo, string>>(0);
                    builder.AddAttribute(1, "Field", "Name");
                    // Original test configuration; possibly using default IgnoreWhenExport value
                    builder.CloseComponent();
                });
            });
        });
        // Original assertions (if applicable) remain here.
        Assert.Contains("Name", cut.Markup);
    }

    [Fact]
    public void IgnoreWhenExport_False_Included()
    {
        // Test that when IgnoreWhenExport is explicitly false, the columns are included.
        var items = new Foo[] { new() { Name = "Name", Address = "Address" } };
        var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
        {
            pb.AddChildContent<Table<Foo>>(pb =>
            {
                pb.Add(a => a.RenderMode, TableRenderMode.Table);
                pb.Add(a => a.Items, items);
                pb.Add(a => a.TableColumns, foo => builder =>
                {
                    builder.OpenComponent<TableColumn<Foo, string>>(0);
                    builder.AddAttribute(1, "Field", "Name");
                    builder.AddAttribute(2, "IgnoreWhenExport", false);
                    builder.CloseComponent();
                    builder.OpenComponent<TableColumn<Foo, string>>(3);
                    builder.AddAttribute(4, "Field", "Address");
                    builder.AddAttribute(5, "IgnoreWhenExport", false);
                    builder.CloseComponent();
                });
            });
        });
        // Verify that both columns' text appears in the output.
        Assert.Contains("Name", cut.Markup);
        Assert.Contains("Address", cut.Markup);
    }

    [Fact]
    public void IgnoreWhenExport_AllTrue_Empty()
    {
        // Test that when all columns are marked with IgnoreWhenExport true the export yields no columns.
        // Depending on the export logic, you might have an export method that returns the export content.
        // Here, we check that the rendered markup does not contain the column values.
        var items = new Foo[] { new() { Name = "Name", Address = "Address" } };
        var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
        {
            pb.AddChildContent<Table<Foo>>(pb =>
            {
                pb.Add(a => a.RenderMode, TableRenderMode.Table);
                pb.Add(a => a.Items, items);
                pb.Add(a => a.TableColumns, foo => builder =>
                {
                    builder.OpenComponent<TableColumn<Foo, string>>(0);
                    builder.AddAttribute(1, "Field", "Name");
                    builder.AddAttribute(2, "IgnoreWhenExport", true);
                    builder.CloseComponent();
                    builder.OpenComponent<TableColumn<Foo, string>>(3);
                    builder.AddAttribute(4, "Field", "Address");
                    builder.AddAttribute(5, "IgnoreWhenExport", true);
                    builder.CloseComponent();
                });
            });
        });
        // No cell content should come through for export
        Assert.DoesNotContain("Name", cut.Markup);
        Assert.DoesNotContain("Address", cut.Markup);
    }

    [Fact]
    public void MultipleColumns_AllIncluded()
    {
        // Test that when multiple columns are defined without any IgnoreWhenExport flag (or default behavior),
        // all columns are included.
        var items = new Foo[] { new() { Name = "Name", Address = "Address", Extra = "Extra" } };
        var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
        {
            pb.AddChildContent<Table<Foo>>(pb =>
            {
                pb.Add(a => a.RenderMode, TableRenderMode.Table);
                pb.Add(a => a.Items, items);
                pb.Add(a => a.TableColumns, foo => builder =>
                {
                    builder.OpenComponent<TableColumn<Foo, string>>(0);
                    builder.AddAttribute(1, "Field", "Name");
                    builder.CloseComponent();
                    builder.OpenComponent<TableColumn<Foo, string>>(2);
                    builder.AddAttribute(3, "Field", "Address");
                    builder.CloseComponent();
                    builder.OpenComponent<TableColumn<Foo, string>>(4);
                    builder.AddAttribute(5, "Field", "Extra");
                    builder.CloseComponent();
                });
            });
        });
        // Verify that all defined columns appear in the markup.
        Assert.Contains("Name", cut.Markup);
        Assert.Contains("Address", cut.Markup);
        Assert.Contains("Extra", cut.Markup);
    }

```

Ensure that the Foo class includes an "Extra" property for the MultipleColumns_AllIncluded test.
Adjust the assertions to match how your table export content is generated if it requires a different mechanism than checking the Markup.
created_at: 2025-05-10T04:07:18Z
author_association: CONTRIBUTOR
diff_hunk: @@ -86,6 +86,7 @@ public void InternalTableColumn_Ok()
         SetValue("IsRequiredWhenAdd", true);
         SetValue("IsRequiredWhenEdit", true);
         SetValue("LookupService", null);
+        SetValue("IgnoreWhenExport", true);
path: test/UnitTest/Components/InternalTableColumnTest.cs
user: login: sourcery-ai[bot]
body: **suggestion (testing):** Consider adding an explicit assertion for the `IgnoreWhenExport` property value.

Retrieve the property and assert it’s true, for example:
```csharp
var actualValue = ((InternalTableColumn)instance).IgnoreWhenExport;
Assert.True(actualValue);
```

```suggestion
        SetValue("IgnoreWhenExport", true);
        var actualValue = ((InternalTableColumn)instance).IgnoreWhenExport;
        Assert.True(actualValue);
```
created_at: 2025-05-10T04:07:19Z
author_association: CONTRIBUTOR

PR comments:
user: login: sourcery-ai[bot]
created_at: 2025-05-10T04:04:06Z
body: <!-- Generated by sourcery-ai[bot]: start review_guide -->

## Reviewer's Guide

This pull request introduces an `IgnoreWhenExport` boolean property to table column configurations, enabling selective exclusion of columns during data export. The implementation involved adding this property to the `ITableColumn` interface and its concrete classes (`TableColumn`, `AutoGenerateColumnAttribute`, `InternalTableColumn`). An extension method `GetIgnoreExport` was added for convenient access, and the `CopyValue` method was updated to include this new property. The core logic change is in `Table.razor.Toolbar.cs`, where `GetVisibleColumns` now filters columns based on `IgnoreWhenExport`. Corresponding unit tests were added and updated to ensure the new feature's correctness.

### File-Level Changes

| Change | Details | Files |
| ------ | ------- | ----- |
| Introduced the `IgnoreWhenExport` property to table column interfaces and classes to allow columns to be skipped during export. | <ul><li>Defined `bool? IgnoreWhenExport` in the `ITableColumn` interface.</li><li>Implemented the `IgnoreWhenExport` property in derived classes.</li></ul> | `src/BootstrapBlazor/Components/Table/ITableColumn.cs`<br/>`src/BootstrapBlazor/Components/Table/TableColumn.cs`<br/>`src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs`<br/>`src/BootstrapBlazor/Components/Table/InternalTableColumn.cs` |
| Integrated the `IgnoreWhenExport` property into the table's export mechanism and column utility functions. | <ul><li>Added `GetIgnoreExport()` helper method to `ITableColumnExtensions` for consistent property evaluation.</li><li>Modified `GetVisibleColumns()` in `Table.razor.Toolbar.cs` to exclude columns marked for export ignorance.</li><li>Updated `CopyValue()` in `ITableColumnExtensions` to handle the new property during column duplication.</li></ul> | `src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs`<br/>`src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs` |
| Added and updated unit tests to verify the behavior of the `IgnoreWhenExport` feature across different scenarios. | <ul><li>Introduced a new test case specifically validating the export filtering logic.</li><li>Updated existing tests for column attributes and utility methods to reflect the new property.</li></ul> | `test/UnitTest/Components/TableTest.cs`<br/>`test/UnitTest/Attributes/AutoGenerateClassTest.cs`<br/>`test/UnitTest/Components/InternalTableColumnTest.cs`<br/>`test/UnitTest/Utils/UtilityTest.cs` |

### Assessment against linked issues

| Issue | Objective | Addressed | Explanation |
| ------ | ------- | ----- | ----- |
| #6009 | Add a property to TableColumn to allow ignoring a column during export. | ✅ |  |

### Possibly linked issues

- **#5991**: PR adds IgnoreWhenExport property to exclude columns from export as requested in the issue.

---

<details>
<summary>Tips and commands</summary>

#### Interacting with Sourcery

- **Trigger a new review:** Comment `@sourcery-ai review` on the pull request.
- **Continue discussions:** Reply directly to Sourcery's review comments.
- **Generate a GitHub issue from a review comment:** Ask Sourcery to create an
  issue from a review comment by replying to it. You can also reply to a
  review comment with `@sourcery-ai issue` to create an issue from it.
- **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull
  request title to generate a title at any time. You can also comment
  `@sourcery-ai title` on the pull request to (re-)generate the title at any time.
- **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in
  the pull request body to generate a PR summary at any time exactly where you
  want it. You can also comment `@sourcery-ai summary` on the pull request to
  (re-)generate the summary at any time.
- **Generate reviewer's guide:** Comment `@sourcery-ai guide` on the pull
  request to (re-)generate the reviewer's guide at any time.
- **Resolve all Sourcery comments:** Comment `@sourcery-ai resolve` on the
  pull request to resolve all Sourcery comments. Useful if you've already
  addressed all the comments and don't want to see them anymore.
- **Dismiss all Sourcery reviews:** Comment `@sourcery-ai dismiss` on the pull
  request to dismiss all existing Sourcery reviews. Especially useful if you
  want to start fresh with a new review - don't forget to comment
  `@sourcery-ai review` to trigger a new review!

#### Customizing Your Experience

Access your [dashboard](https://app.sourcery.ai) to:
- Enable or disable review features such as the Sourcery-generated pull request
  summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.

#### Getting Help

- [Contact our support team](mailto:support@sourcery.ai) for questions or feedback.
- Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information.
- Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).

</details>

<!-- Generated by sourcery-ai[bot]: end review_guide -->
author_association: CONTRIBUTOR
user: login: codecov[bot]
created_at: 2025-05-10T04:06:20Z
body: ## [Codecov](https://app.codecov.io/gh/dotnetcore/BootstrapBlazor/pull/6011?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnetcore) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`f89a1fa`)](https://app.codecov.io/gh/dotnetcore/BootstrapBlazor/commit/f89a1fa933c8d1ec2cab8615a589275efb6f4ada?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnetcore) to head [(`38cf1e1`)](https://app.codecov.io/gh/dotnetcore/BootstrapBlazor/commit/38cf1e192173238761b456a5f503c6b44df3b1d4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnetcore).
> Report is 1 commits behind head on main.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##              main     #6011   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          670       670           
  Lines        30646     30651    +5     
  Branches      4361      4362    +1     
=========================================
+ Hits         30646     30651    +5     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/dotnetcore/BootstrapBlazor/pull/6011?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnetcore).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnetcore).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
author_association: NONE