static void SpecifyChartSettings(IWorkbook workbook) { #region #SpecifyChartSettings Worksheet worksheet = workbook.Worksheets["chartTask2"]; // Create an empty chart sheet of the specified type. ChartSheet chartSheet = workbook.ChartSheets.Add(ChartType.BarFullStacked); // Access a chart on the chart sheet. ChartObject chart = chartSheet.Chart; // Select chart data. chart.SelectData(worksheet["B3:C8"], ChartDataDirection.Row); // Display the chart title. chart.Title.Visible = true; chart.Title.SetReference(worksheet["B1"]); // Change the legend position. chart.Legend.Position = LegendPosition.Bottom; // Hide the category axis. chart.PrimaryAxes[0].Visible = false; // Set the value axis' major unit. chart.PrimaryAxes[1].MajorUnit = 0.2; workbook.ChartSheets.ActiveChartSheet = chartSheet; #endregion #SpecifyChartSettings }