Skip to content

Commit c585ca4

Browse files
authored
Merge pull request #310 from SyncfusionExamples/1003194-Hidden-Column
UG documentation 1003194: FAQ for how to detect whether a column is hidden in an Excel file using XlsIO
2 parents 0eee9c4 + db9bbbb commit c585ca4

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Hidden Column/Hidden Column.csproj" />
3+
</Solution>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Hidden_Column</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Output\*">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
</Project>

FAQ/Hidden Column/.NET/Hidden Column/Hidden Column/Output/.gitkeep

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Syncfusion.XlsIO;
2+
using Syncfusion.XlsIO.Implementation;
3+
4+
class Program
5+
{
6+
static void Main(string[] args)
7+
{
8+
using (ExcelEngine excelEngine = new ExcelEngine())
9+
{
10+
IApplication application = excelEngine.Excel;
11+
application.DefaultVersion = ExcelVersion.Xlsx;
12+
IWorkbook workbook = application.Workbooks.Create(1);
13+
14+
// Use the concrete WorksheetImpl when you need access to implementation-specific members
15+
WorksheetImpl sheet = workbook.Worksheets[0] as WorksheetImpl;
16+
17+
// Hide column 1
18+
sheet.ShowColumn(1, false);
19+
20+
// Detect whether column 1 is hidden
21+
bool hidden = sheet.ColumnInformation[1] != null && sheet.ColumnInformation[1].IsHidden;
22+
23+
Console.WriteLine($"Column 1 hidden: {hidden}");
24+
25+
workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx"));
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)