File tree Expand file tree Collapse file tree
FAQ/Chart/.NET/ChartProperties Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <Solution >
2+ <Project Path =" ChartProperties/ChartProperties.csproj" />
3+ </Solution >
Original file line number Diff line number Diff line change 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 =" Data\*" >
16+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
17+ </None >
18+ <None Update =" Output\*" >
19+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
20+ </None >
21+ </ItemGroup >
22+
23+ </Project >
Original file line number Diff line number Diff line change 1+ using System ;
2+ using Syncfusion . XlsIO ;
3+
4+ namespace ChartProperties
5+ {
6+ class Program
7+ {
8+ static void Main ( string [ ] args )
9+ {
10+ using ( ExcelEngine excelEngine = new ExcelEngine ( ) )
11+ {
12+ #region Workbook Initialization
13+ IApplication application = excelEngine . Excel ;
14+ application . DefaultVersion = ExcelVersion . Xlsx ;
15+ IWorkbook workbook = application . Workbooks . Open ( Path . GetFullPath ( @"Data/InputTemplate.xlsx" ) ) ;
16+ IWorksheet worksheet = workbook . Worksheets [ 0 ] ;
17+ #endregion
18+
19+ //Create a Chart
20+ IChartShape chart = workbook . Worksheets [ 0 ] . Charts . Add ( ) ;
21+
22+ chart . DataRange = worksheet . Range [ "A3:C15" ] ;
23+ chart . ChartType = ExcelChartType . Column_Clustered ;
24+ chart . IsSeriesInRows = false ;
25+
26+ //Formatting the chart
27+ chart . ChartTitle = "Crescent City, CA" ;
28+ chart . ChartTitleArea . FontName = "Calibri" ;
29+ chart . ChartTitleArea . Size = 14 ;
30+ chart . ChartTitleArea . Bold = true ;
31+ chart . ChartTitleArea . Color = ExcelKnownColors . Red ;
32+
33+ //Embedded Chart Position
34+ chart . TopRow = 2 ;
35+ chart . BottomRow = 30 ;
36+ chart . LeftColumn = 5 ;
37+ chart . RightColumn = 18 ;
38+
39+ #region Save
40+ //Saving the workbook
41+ workbook . SaveAs ( Path . GetFullPath ( "Output/Output.xlsx" ) ) ;
42+ #endregion
43+ }
44+ }
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments