diff --git a/README.md b/README.md index 3328916f..bae50995 100644 --- a/README.md +++ b/README.md @@ -1073,7 +1073,18 @@ public class Dto } ``` -#### 4. Multiple column names mapping to the same property. +#### 4. Set Column Visibility(MiniExcelHiddenAttribute) +```csharp +public class Dto +{ + public string Name { get; set; } + + [ExcelHidden] + public int SecretPoints { get; set; } +} +``` + +#### 5. Multiple column names mapping to the same property. ```csharp public class Dto @@ -1084,9 +1095,7 @@ public class Dto } ``` - - -#### 5. System.ComponentModel.DisplayNameAttribute = ExcelColumnName.excelColumnNameAttribute +#### 6. System.ComponentModel.DisplayNameAttribute = ExcelColumnName.excelColumnNameAttribute Since 1.24.0, system supports System.ComponentModel.DisplayNameAttribute = ExcelColumnName.excelColumnNameAttribute @@ -1102,9 +1111,7 @@ public class TestIssueI4TXGTDto } ``` - - -#### 6. ExcelColumnAttribute +#### 7. ExcelColumnAttribute Since V1.26.0, multiple attributes can be simplified like : ```csharp @@ -1114,12 +1121,12 @@ Since V1.26.0, multiple attributes can be simplified like : public string MyProperty { get; set; } [ExcelColumn(Name = "CreateDate", Index = 1,Format ="yyyy-MM",Width =100)] public DateTime MyProperty2 { get; set; } + [ExcelColumn(Name = "SecretColumn", Hidden = true)] + public int MyProperty3 { get; set; } } ``` - - -#### 7. DynamicColumnAttribute +#### 8. DynamicColumnAttribute Since V1.26.0, we can set the attributes of Column dynamically ```csharp @@ -1138,7 +1145,7 @@ Since V1.26.0, we can set the attributes of Column dynamically ``` ![image](https://user-images.githubusercontent.com/12729184/164510353-5aecbc4e-c3ce-41e8-b6cf-afd55eb23b68.png) -#### 8. DynamicSheetAttribute +#### 9. DynamicSheetAttribute Since V1.31.4 we can set the attributes of Sheet dynamically. We can set sheet name and state (visibility). ```csharp diff --git a/src/MiniExcel/Attributes/ExcelColumnAttribute.cs b/src/MiniExcel/Attributes/ExcelColumnAttribute.cs index 36211b8f..70d0c203 100644 --- a/src/MiniExcel/Attributes/ExcelColumnAttribute.cs +++ b/src/MiniExcel/Attributes/ExcelColumnAttribute.cs @@ -13,8 +13,9 @@ public class ExcelColumnAttribute : Attribute public string Name { get; set; } public string[] Aliases { get; set; } - public double Width { get; set; } = 9.28515625; + public double Width { get; set; } = 8.42857143; public string Format { get; set; } + public bool Hidden { get; set; } public bool Ignore { get; set; } public ColumnType Type { get; set; } = ColumnType.Value; diff --git a/src/MiniExcel/Attributes/ExcelHiddenAttribute.cs b/src/MiniExcel/Attributes/ExcelHiddenAttribute.cs new file mode 100644 index 00000000..fcda446a --- /dev/null +++ b/src/MiniExcel/Attributes/ExcelHiddenAttribute.cs @@ -0,0 +1,11 @@ +using System; + +namespace MiniExcelLibs.Attributes +{ + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] + public class ExcelHiddenAttribute : Attribute + { + public bool ExcelHidden { get; set; } + public ExcelHiddenAttribute(bool excelHidden = true) => ExcelHidden = excelHidden; + } +} diff --git a/src/MiniExcel/MiniExcelLibs.csproj b/src/MiniExcel/MiniExcelLibs.csproj index 9b960d12..e3642133 100644 --- a/src/MiniExcel/MiniExcelLibs.csproj +++ b/src/MiniExcel/MiniExcelLibs.csproj @@ -1,7 +1,7 @@  net45;netstandard2.0;net8.0;net9.0;net10.0 - 1.42.0 + 1.43.0 8 diff --git a/src/MiniExcel/OpenXml/Constants/WorksheetXml.cs b/src/MiniExcel/OpenXml/Constants/WorksheetXml.cs index 50cdcbc7..37ece9d3 100644 --- a/src/MiniExcel/OpenXml/Constants/WorksheetXml.cs +++ b/src/MiniExcel/OpenXml/Constants/WorksheetXml.cs @@ -16,8 +16,8 @@ internal static class WorksheetXml internal const string StartSheetViews = ""; internal const string EndSheetViews = ""; - internal static string StartSheetView( int tabSelected=0, int workbookViewId=0 ) - => $""; + internal static string StartSheetView(int tabSelected = 0, int workbookViewId = 0, bool rightToLeft = false) + => $""; internal const string EndSheetView = ""; internal const string StartSheetData = ""; @@ -45,10 +45,10 @@ internal static string PaneSelection( string pane, string activeCell, string sqr internal const string EndRow = ""; internal const string StartCols = ""; - internal static string Column(int colIndex, double columnWidth) - => $@""; + internal static string Column(int colIndex, double columnWidth, bool hidden = false) + => $@"