Skip to content

Commit 9f40be3

Browse files
authored
Merge pull request #276 from SyncfusionExamples/991689-Merged-Cellstyle
991689-How to apply border styles for merged cells
2 parents 7a25fd7 + cf775b8 commit 9f40be3

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Borderstylesformergedcells/Borderstylesformergedcells.csproj" />
3+
</Solution>
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+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
20+
</Project>

FAQ/Border styles for merged cells/.NET/Borderstylesformergedcells/Borderstylesformergedcells/Output/.gitkeep

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Syncfusion.XlsIO;
2+
3+
namespace Sample
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
using (ExcelEngine excelEngine = new ExcelEngine())
10+
{
11+
IApplication application = excelEngine.Excel;
12+
application.DefaultVersion = ExcelVersion.Xlsx;
13+
IWorkbook workbook = application.Workbooks.Open("../../../Data/Input.xlsx");
14+
IWorksheet worksheet = workbook.Worksheets[0];
15+
16+
# region Creating a new style
17+
IStyle style = workbook.Styles.Add("NewStyle");
18+
19+
style.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thick;
20+
style.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thick;
21+
style.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thick;
22+
style.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thick;
23+
style.Borders.Color = ExcelKnownColors.Red;
24+
25+
style.Font.Bold = true;
26+
style.Font.Color = ExcelKnownColors.Green;
27+
style.Font.Size = 24;
28+
#endregion
29+
30+
//Applying style for merged region
31+
worksheet.Range[2, 1].MergeArea.CellStyle = style;
32+
33+
workbook.SaveAs("../../../Output/MergeArea_Style.xlsx");
34+
}
35+
}
36+
37+
38+
}
39+
40+
}

0 commit comments

Comments
 (0)