diff --git a/FAQ/Chart/.NET/ChartProperties/ChartProperties.slnx b/FAQ/Chart/.NET/ChartProperties/ChartProperties.slnx new file mode 100644 index 00000000..40ae02c8 --- /dev/null +++ b/FAQ/Chart/.NET/ChartProperties/ChartProperties.slnx @@ -0,0 +1,3 @@ + + + diff --git a/FAQ/Chart/.NET/ChartProperties/ChartProperties/ChartProperties.csproj b/FAQ/Chart/.NET/ChartProperties/ChartProperties/ChartProperties.csproj new file mode 100644 index 00000000..7b9d981b --- /dev/null +++ b/FAQ/Chart/.NET/ChartProperties/ChartProperties/ChartProperties.csproj @@ -0,0 +1,23 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/FAQ/Chart/.NET/ChartProperties/ChartProperties/Data/InputTemplate.xlsx b/FAQ/Chart/.NET/ChartProperties/ChartProperties/Data/InputTemplate.xlsx new file mode 100644 index 00000000..b9e36a87 Binary files /dev/null and b/FAQ/Chart/.NET/ChartProperties/ChartProperties/Data/InputTemplate.xlsx differ diff --git a/FAQ/Chart/.NET/ChartProperties/ChartProperties/Output/.gitkeep b/FAQ/Chart/.NET/ChartProperties/ChartProperties/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/FAQ/Chart/.NET/ChartProperties/ChartProperties/Program.cs b/FAQ/Chart/.NET/ChartProperties/ChartProperties/Program.cs new file mode 100644 index 00000000..95f014cb --- /dev/null +++ b/FAQ/Chart/.NET/ChartProperties/ChartProperties/Program.cs @@ -0,0 +1,46 @@ +using System; +using Syncfusion.XlsIO; + +namespace ChartProperties +{ + class Program + { + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + #region Workbook Initialization + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + IWorksheet worksheet = workbook.Worksheets[0]; + #endregion + + //Create a Chart + IChartShape chart = workbook.Worksheets[0].Charts.Add(); + + chart.DataRange = worksheet.Range["A3:C15"]; + chart.ChartType = ExcelChartType.Column_Clustered; + chart.IsSeriesInRows = false; + + //Formatting the chart + chart.ChartTitle = "Crescent City, CA"; + chart.ChartTitleArea.FontName = "Calibri"; + chart.ChartTitleArea.Size = 14; + chart.ChartTitleArea.Bold = true; + chart.ChartTitleArea.Color = ExcelKnownColors.Red; + + //Embedded Chart Position + chart.TopRow = 2; + chart.BottomRow = 30; + chart.LeftColumn = 5; + chart.RightColumn = 18; + + #region Save + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); + #endregion + } + } + } +}