diff --git a/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting.slnx b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting.slnx new file mode 100644 index 00000000..2191161c --- /dev/null +++ b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting.slnx @@ -0,0 +1,3 @@ + + + diff --git a/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Data/InputTemplate.xlsx b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Data/InputTemplate.xlsx new file mode 100644 index 00000000..a908fbf0 Binary files /dev/null and b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Data/InputTemplate.xlsx differ diff --git a/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Merge Cells Formatting.csproj b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Merge Cells Formatting.csproj new file mode 100644 index 00000000..03291ade --- /dev/null +++ b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Merge Cells Formatting.csproj @@ -0,0 +1,23 @@ + + + + Exe + net8.0 + Merge_Cells_Formatting + enable + enable + + + + + + + + Always + + + Always + + + + diff --git a/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Output/.gitkeep b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Program.cs b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Program.cs new file mode 100644 index 00000000..600f7f4f --- /dev/null +++ b/FAQ/Merge Cells Formatting/.NET/Merge Cells Formatting/Merge Cells Formatting/Program.cs @@ -0,0 +1,20 @@ +using Syncfusion.XlsIO; + +class Program +{ + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + IWorksheet worksheet = workbook.Worksheets[0]; + + // Merge: true preserves top-left value and copies top-left formatting to merged area + worksheet.Range["B8:C11"].Merge(); + + workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx")); + } + } +}