From 404e83c651082288aed0a1b091acbc210e566832 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Fri, 19 Dec 2025 13:28:57 +0530 Subject: [PATCH 1/4] 992308-FontStyle --- ...ply-font-styles-to-the-entire-worksheet.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md new file mode 100644 index 000000000..23441a2c5 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md @@ -0,0 +1,104 @@ +--- +title: How to apply styles to an Entire Excel Worksheet | Syncfusion +description: Learn how to apply font settings and fill color to an entire Excel worksheet using the Syncfusion .NET Excel library (XlsIO) in C# and VB.NET. +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to apply styles to the entire worksheet in Excel using C#? + +The following examples show how to apply font attributes (name and size) and fill color to an entire worksheet using C# (cross-platform and Windows-specific) and VB.NET. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("../../../Data/Input.xlsx", ExcelOpenType.Automatic); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Define new styles to apply in rows and columns + IStyle columnStyle = workbook.Styles.Add("ColumnStyle"); + columnStyle.Font.FontName = "Times New Roman"; + columnStyle.Font.Size = 10; + columnStyle.Color = Color.Pink; + + worksheet.SetDefaultColumnStyle(1, 16384, columnStyle); + + //Save the Excel document + workbook.SaveAs("../../../Output/FontStyle.xlsx"); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("../../Data/Input.xlsx", ExcelOpenType.Automatic); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Define new styles to apply in rows and columns + IStyle columnStyle = workbook.Styles.Add("ColumnStyle"); + columnStyle.Font.FontName = "Times New Roman"; + columnStyle.Font.Size = 10; + columnStyle.Color = Color.Pink; + + worksheet.SetDefaultColumnStyle(1, 16384, columnStyle); + + //Save the Excel document + workbook.SaveAs("../../Output/FontStyle.xlsx"); + +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + + Dim workbook As IWorkbook = application.Workbooks.Open("../../Data/Input.xlsx", ExcelOpenType.Automatic) + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + 'Define new styles to apply in rows and columns + Dim columnStyle As IStyle = workbook.Styles.Add("ColumnStyle") + columnStyle.Font.FontName = "Times New Roman" + columnStyle.Font.Size = 10 + columnStyle.Color = Color.Pink + + worksheet.SetDefaultColumnStyle(1, 16384, columnStyle) + + 'Save the Excel document + workbook.SaveAs("../../Output/FontStyle.xlsx") +End Using +{% endhighlight %} +{% endtabs %} + +N> +* Applying a default style to cells replaces any existing styles. This is standard Excel behavior. +* To add new styling without removing existing formats, set specific properties on targeted ranges. + +The following code snippet shows how to apply a new style without affecting existing styles: + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} + worksheet.Range["A1:F13"].CellStyle.Font.FontName = "Times New Roman"; + worksheet.Range["A1:F13"].CellStyle.Font.Size = 10; + worksheet.Range["A1:F13"].CellStyle.Color = Color.Lavender; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} + worksheet.Range["A1:F13"].CellStyle.Font.FontName = "Times New Roman"; + worksheet.Range["A1:F13"].CellStyle.Font.Size = 10; + worksheet.Range["A1:F13"].CellStyle.Color = Color.Lavender; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +worksheet.Range("A1:F13").CellStyle.Font.FontName = "Times New Roman" +worksheet.Range("A1:F13").CellStyle.Font.Size = 10 +worksheet.Range("A1:F13").CellStyle.Color = Color.Lavender +{% endhighlight %} +{% endtabs %} + From f39265120ac833bfdf316b19d1ca14b9f656c0b7 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Fri, 19 Dec 2025 13:53:21 +0530 Subject: [PATCH 2/4] 992308-FontStyle --- .../faqs/How-to-apply-font-styles-to-the-entire-worksheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md index 23441a2c5..726a4872a 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md @@ -6,7 +6,7 @@ control: XlsIO documentation: UG --- -# How to apply styles to the entire worksheet in Excel using C#? +# How to apply styles to the entire worksheet in Excel? The following examples show how to apply font attributes (name and size) and fill color to an entire worksheet using C# (cross-platform and Windows-specific) and VB.NET. From 42c2855ba89ec329931342c1f2303f7fc6866e0a Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Fri, 19 Dec 2025 14:15:13 +0530 Subject: [PATCH 3/4] 992308-FontStyle --- ...ply-font-styles-to-the-entire-worksheet.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-font-styles-to-the-entire-worksheet.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-font-styles-to-the-entire-worksheet.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-font-styles-to-the-entire-worksheet.md new file mode 100644 index 000000000..726a4872a --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-font-styles-to-the-entire-worksheet.md @@ -0,0 +1,104 @@ +--- +title: How to apply styles to an Entire Excel Worksheet | Syncfusion +description: Learn how to apply font settings and fill color to an entire Excel worksheet using the Syncfusion .NET Excel library (XlsIO) in C# and VB.NET. +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to apply styles to the entire worksheet in Excel? + +The following examples show how to apply font attributes (name and size) and fill color to an entire worksheet using C# (cross-platform and Windows-specific) and VB.NET. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("../../../Data/Input.xlsx", ExcelOpenType.Automatic); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Define new styles to apply in rows and columns + IStyle columnStyle = workbook.Styles.Add("ColumnStyle"); + columnStyle.Font.FontName = "Times New Roman"; + columnStyle.Font.Size = 10; + columnStyle.Color = Color.Pink; + + worksheet.SetDefaultColumnStyle(1, 16384, columnStyle); + + //Save the Excel document + workbook.SaveAs("../../../Output/FontStyle.xlsx"); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("../../Data/Input.xlsx", ExcelOpenType.Automatic); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Define new styles to apply in rows and columns + IStyle columnStyle = workbook.Styles.Add("ColumnStyle"); + columnStyle.Font.FontName = "Times New Roman"; + columnStyle.Font.Size = 10; + columnStyle.Color = Color.Pink; + + worksheet.SetDefaultColumnStyle(1, 16384, columnStyle); + + //Save the Excel document + workbook.SaveAs("../../Output/FontStyle.xlsx"); + +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + + Dim workbook As IWorkbook = application.Workbooks.Open("../../Data/Input.xlsx", ExcelOpenType.Automatic) + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + 'Define new styles to apply in rows and columns + Dim columnStyle As IStyle = workbook.Styles.Add("ColumnStyle") + columnStyle.Font.FontName = "Times New Roman" + columnStyle.Font.Size = 10 + columnStyle.Color = Color.Pink + + worksheet.SetDefaultColumnStyle(1, 16384, columnStyle) + + 'Save the Excel document + workbook.SaveAs("../../Output/FontStyle.xlsx") +End Using +{% endhighlight %} +{% endtabs %} + +N> +* Applying a default style to cells replaces any existing styles. This is standard Excel behavior. +* To add new styling without removing existing formats, set specific properties on targeted ranges. + +The following code snippet shows how to apply a new style without affecting existing styles: + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} + worksheet.Range["A1:F13"].CellStyle.Font.FontName = "Times New Roman"; + worksheet.Range["A1:F13"].CellStyle.Font.Size = 10; + worksheet.Range["A1:F13"].CellStyle.Color = Color.Lavender; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} + worksheet.Range["A1:F13"].CellStyle.Font.FontName = "Times New Roman"; + worksheet.Range["A1:F13"].CellStyle.Font.Size = 10; + worksheet.Range["A1:F13"].CellStyle.Color = Color.Lavender; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +worksheet.Range("A1:F13").CellStyle.Font.FontName = "Times New Roman" +worksheet.Range("A1:F13").CellStyle.Font.Size = 10 +worksheet.Range("A1:F13").CellStyle.Color = Color.Lavender +{% endhighlight %} +{% endtabs %} + From 0998ad52bc27ce79b7a0cfc72f8f87a7bcadc8cf Mon Sep 17 00:00:00 2001 From: SivakumarRamya <93247345+SivakumarRamya@users.noreply.github.com> Date: Fri, 19 Dec 2025 14:28:13 +0530 Subject: [PATCH 4/4] Delete Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md --- ...ply-font-styles-to-the-entire-worksheet.md | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md deleted file mode 100644 index 726a4872a..000000000 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-apply-font-styles-to-the-entire-worksheet.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: How to apply styles to an Entire Excel Worksheet | Syncfusion -description: Learn how to apply font settings and fill color to an entire Excel worksheet using the Syncfusion .NET Excel library (XlsIO) in C# and VB.NET. -platform: document-processing -control: XlsIO -documentation: UG ---- - -# How to apply styles to the entire worksheet in Excel? - -The following examples show how to apply font attributes (name and size) and fill color to an entire worksheet using C# (cross-platform and Windows-specific) and VB.NET. - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open("../../../Data/Input.xlsx", ExcelOpenType.Automatic); - IWorksheet worksheet = workbook.Worksheets[0]; - - //Define new styles to apply in rows and columns - IStyle columnStyle = workbook.Styles.Add("ColumnStyle"); - columnStyle.Font.FontName = "Times New Roman"; - columnStyle.Font.Size = 10; - columnStyle.Color = Color.Pink; - - worksheet.SetDefaultColumnStyle(1, 16384, columnStyle); - - //Save the Excel document - workbook.SaveAs("../../../Output/FontStyle.xlsx"); -} -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open("../../Data/Input.xlsx", ExcelOpenType.Automatic); - IWorksheet worksheet = workbook.Worksheets[0]; - - //Define new styles to apply in rows and columns - IStyle columnStyle = workbook.Styles.Add("ColumnStyle"); - columnStyle.Font.FontName = "Times New Roman"; - columnStyle.Font.Size = 10; - columnStyle.Color = Color.Pink; - - worksheet.SetDefaultColumnStyle(1, 16384, columnStyle); - - //Save the Excel document - workbook.SaveAs("../../Output/FontStyle.xlsx"); - -} -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As New ExcelEngine() - Dim application As IApplication = excelEngine.Excel - application.DefaultVersion = ExcelVersion.Xlsx - - Dim workbook As IWorkbook = application.Workbooks.Open("../../Data/Input.xlsx", ExcelOpenType.Automatic) - Dim worksheet As IWorksheet = workbook.Worksheets(0) - - 'Define new styles to apply in rows and columns - Dim columnStyle As IStyle = workbook.Styles.Add("ColumnStyle") - columnStyle.Font.FontName = "Times New Roman" - columnStyle.Font.Size = 10 - columnStyle.Color = Color.Pink - - worksheet.SetDefaultColumnStyle(1, 16384, columnStyle) - - 'Save the Excel document - workbook.SaveAs("../../Output/FontStyle.xlsx") -End Using -{% endhighlight %} -{% endtabs %} - -N> -* Applying a default style to cells replaces any existing styles. This is standard Excel behavior. -* To add new styling without removing existing formats, set specific properties on targeted ranges. - -The following code snippet shows how to apply a new style without affecting existing styles: - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} - worksheet.Range["A1:F13"].CellStyle.Font.FontName = "Times New Roman"; - worksheet.Range["A1:F13"].CellStyle.Font.Size = 10; - worksheet.Range["A1:F13"].CellStyle.Color = Color.Lavender; -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} - worksheet.Range["A1:F13"].CellStyle.Font.FontName = "Times New Roman"; - worksheet.Range["A1:F13"].CellStyle.Font.Size = 10; - worksheet.Range["A1:F13"].CellStyle.Color = Color.Lavender; -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -worksheet.Range("A1:F13").CellStyle.Font.FontName = "Times New Roman" -worksheet.Range("A1:F13").CellStyle.Font.Size = 10 -worksheet.Range("A1:F13").CellStyle.Color = Color.Lavender -{% endhighlight %} -{% endtabs %} -