diff --git a/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/README.md b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/README.md new file mode 100644 index 00000000..2e86dd3f --- /dev/null +++ b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/README.md @@ -0,0 +1,42 @@ +# How to set the default font and font size in an Excel Workbook? + +Step 1: Create a New C# Console Application Project. + +Step 2: Name the Project. + +Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org). + +Step 4: Include the following namespaces in the **Program.cs** file. + +```csharp +using System; +using System.IO; +using Syncfusion.XlsIO; +``` + +Step 5: Include the below code snippet in **Program.cs** to set the default font and font size in an Excel Workbook. + +```csharp +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet sheet = workbook.Worksheets[0]; + + //Set default font and font size + workbook.StandardFont = "Calibri"; + workbook.StandardFontSize = 12; + + //Add some text + sheet.Range["A1"].Text = "This is default font and size"; + + //Save to file + FileStream outputStream = new FileStream("Output/Output.xlsx", FileMode.Create, FileAccess.Write); + workbook.SaveAs(outputStream); + + //Dispose streams + outputStream.Dispose(); + +} +``` \ No newline at end of file diff --git a/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size.sln b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size.sln new file mode 100644 index 00000000..f6f15923 --- /dev/null +++ b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35506.116 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Workbook default font and font size", "Workbook default font and font size\Workbook default font and font size.csproj", "{AF27E864-4757-4976-9331-AC39FB5F151F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF27E864-4757-4976-9331-AC39FB5F151F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF27E864-4757-4976-9331-AC39FB5F151F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF27E864-4757-4976-9331-AC39FB5F151F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF27E864-4757-4976-9331-AC39FB5F151F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Output/.gitkeep b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Program.cs b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Program.cs new file mode 100644 index 00000000..e81e353c --- /dev/null +++ b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; +using Syncfusion.XlsIO; + +namespace WorkbookDefaultFontAndFontSize +{ + class Program + { + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet sheet = workbook.Worksheets[0]; + + //Set default font and font size + workbook.StandardFont = "Calibri"; + workbook.StandardFontSize = 12; + + //Add some text + sheet.Range["A1"].Text = "This is default font and size"; + + //Save to file + FileStream outputStream = new FileStream("Output/Output.xlsx", FileMode.Create, FileAccess.Write); + workbook.SaveAs(outputStream); + + //Dispose streams + outputStream.Dispose(); + + } + } + } +} \ No newline at end of file diff --git a/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Workbook default font and font size.csproj b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Workbook default font and font size.csproj new file mode 100644 index 00000000..874302fc --- /dev/null +++ b/FAQ/Workbook default font and font size/.NET/Workbook default font and font size/Workbook default font and font size/Workbook default font and font size.csproj @@ -0,0 +1,21 @@ + + + + Exe + net8.0 + Workbook_default_font_and_font_size + enable + enable + + + + + + + + + Always + + + +