//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); //Load template file Monthly business budget.xlsx from resource var fileStream = this.GetResourceStream("xlsx\\Monthly business budget.xlsx"); workbook.Open(fileStream); var worksheet = workbook.ActiveSheet; // change chart type to column stacked var chart = worksheet.Shapes[0].Chart; chart.ChartType = ChartType.ColumnStacked; chart.ColumnGroups[0].Overlap = 100; // set font size for chart title chart.ChartTitle.Text = "ESTIMATED v/s ACTUAL BUDGET"; chart.ChartTitle.Font.Size = 14; chart.ChartTitle.Font.Name = "Calibri"; // config chart area line, font and color chart.ChartArea.Format.Fill.Color.RGB = Color.White; chart.ChartArea.Font.Color.RGB = Color.FromArgb(89, 89, 89); chart.ChartArea.Format.Line.Visible = true; chart.ChartArea.Format.Line.Color.RGB = Color.FromArgb(217, 217, 217); // make fill of plot area transparant chart.PlotArea.Format.Fill.Transparency = 1; // config series1 of chart ISeries series1 = chart.SeriesCollection[0]; series1.HasDataLabels = true; series1.Format.Line.Visible = false; series1.Format.Fill.Color.RGB = Color.FromArgb(98, 121, 158); series1.DataLabels.Font.Color.RGB = Color.FromArgb(64, 64, 64); // config series2 of chart ISeries series2 = chart.SeriesCollection[1]; series2.HasDataLabels = true; series2.Format.Line.Visible = false; series2.Format.Fill.Color.RGB = Color.FromArgb(179, 192, 53); series2.DataLabels.Font.Color.RGB = Color.FromArgb(64, 64, 64); // get the value axis IAxis value_axis = chart.Axes.Item(AxisType.Value, AxisGroup.Primary); // config value_axis of chart value_axis.HasTitle = true; value_axis.HasDisplayUnitLabel = false; value_axis.AxisTitle.Text = "AMOUNT (in thousands)"; value_axis.DisplayUnit = DisplayUnit.Thousands; value_axis.MajorGridlines.Format.Line.Color.RGB = Color.FromArgb(217, 217, 217); value_axis.MajorTickMark = TickMark.None; value_axis.Format.Line.Visible = false; chart.Axes.Item(AxisType.Category).Format.Line.Visible = false; // Save to an excel file workbook.Save("MonthlyBusinessBudget.xlsx");
' Create a new Workbook Dim workbook As New Workbook 'Load template file Monthly business budget.xlsx from resource Dim fileStream = GetResourceStream("xlsx\Monthly business budget.xlsx") workbook.Open(fileStream) Dim worksheet = workbook.ActiveSheet ' change chart type to column stacked Dim chart = worksheet.Shapes(0).Chart chart.ChartType = ChartType.ColumnStacked chart.ColumnGroups(0).Overlap = 100 ' set font size for chart title chart.ChartTitle.Text = "ESTIMATED v/s ACTUAL BUDGET" chart.ChartTitle.Font.Size = 14 chart.ChartTitle.Font.Name = "Calibri" ' config chart area line, font and color chart.ChartArea.Format.Fill.Color.RGB = Color.White chart.ChartArea.Font.Color.RGB = Color.FromArgb(89, 89, 89) chart.ChartArea.Format.Line.Visible = True chart.ChartArea.Format.Line.Color.RGB = Color.FromArgb(217, 217, 217) ' make fill of plot area transparant chart.PlotArea.Format.Fill.Transparency = 1 ' config series1 of chart Dim series1 As ISeries = chart.SeriesCollection(0) series1.HasDataLabels = True series1.Format.Line.Visible = False series1.Format.Fill.Color.RGB = Color.FromArgb(98, 121, 158) series1.DataLabels.Font.Color.RGB = Color.FromArgb(64, 64, 64) ' config series2 of chart Dim series2 As ISeries = chart.SeriesCollection(1) series2.HasDataLabels = True series2.Format.Line.Visible = False series2.Format.Fill.Color.RGB = Color.FromArgb(179, 192, 53) series2.DataLabels.Font.Color.RGB = Color.FromArgb(64, 64, 64) ' get the value axis Dim value_axis As IAxis = chart.Axes.Item(AxisType.Value, AxisGroup.Primary) ' config value_axis of chart value_axis.HasTitle = True value_axis.HasDisplayUnitLabel = False value_axis.AxisTitle.Text = "AMOUNT (in thousands)" value_axis.DisplayUnit = DisplayUnit.Thousands value_axis.MajorGridlines.Format.Line.Color.RGB = Color.FromArgb(217, 217, 217) value_axis.MajorTickMark = TickMark.None value_axis.Format.Line.Visible = False chart.Axes.Item(AxisType.Category).Format.Line.Visible = False ' save to an excel file workbook.Save("MonthlyBusinessBudget.xlsx")