예제 #1
0
        private void CreateChart(Worksheet sheet, Chart chart)
        {
            //Set region of chart data
            chart.DataRange           = sheet.Range["B1:B12"];
            chart.SeriesDataFromRange = false;

            //Set position of chart
            chart.LeftColumn  = 3;
            chart.TopRow      = 6;
            chart.RightColumn = 11;
            chart.BottomRow   = 29;


            //Chart title
            chart.ChartTitle            = "Reflex Time Analysis";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size   = 12;

            chart.PrimaryCategoryAxis.Title            = "Age";
            chart.PrimaryCategoryAxis.Font.IsBold      = true;
            chart.PrimaryCategoryAxis.TitleArea.IsBold = true;

            chart.PrimaryValueAxis.Title                       = "Reflex Time";
            chart.PrimaryValueAxis.HasMajorGridLines           = false;
            chart.PrimaryValueAxis.TitleArea.IsBold            = true;
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;



            Charts.ChartSerie cs = chart.Series[0];
            cs.CategoryLabels = sheet.Range["A2:A12"];
        }
예제 #2
0
        private void CreateColumnChart(Worksheet sheet, Chart chart)
        {
            //Set region of chart data
            chart.DataRange           = sheet.Range["B1:B5"];
            chart.SeriesDataFromRange = false;

            //Set position of chart
            chart.LeftColumn  = 1;
            chart.TopRow      = 6;
            chart.RightColumn = 11;
            chart.BottomRow   = 29;


            //Chart title
            chart.ChartTitle            = "Sales by year";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size   = 12;

            chart.PrimaryCategoryAxis.Title                       = "Year";
            chart.PrimaryCategoryAxis.Font.IsBold                 = true;
            chart.PrimaryCategoryAxis.TitleArea.IsBold            = true;
            chart.PrimaryCategoryAxis.TitleArea.TextRotationAngle = 90;

            chart.PrimaryValueAxis.Title             = "Sales(in Dollars)";
            chart.PrimaryValueAxis.HasMajorGridLines = false;
            chart.PrimaryValueAxis.MinValue          = 1000;
            chart.PrimaryValueAxis.TitleArea.IsBold  = true;


            Charts.ChartSerie cs = chart.Series[0];
            cs.CategoryLabels = sheet.Range["A2:A5"];
        }
예제 #3
0
        private void btnRun_Click(object sender, System.EventArgs e)
        {
            Workbook workbook = new Workbook();

            //Initailize worksheet
            workbook.CreateEmptySheets(1);
            Worksheet sheet = workbook.Worksheets[0];

            sheet.Name             = "Chart data";
            sheet.GridLinesVisible = false;

            //Writes chart data
            CreateChartData(sheet);
            //Add a new  chart worsheet to workbook
            Chart chart = sheet.Charts.Add();

            //Set region of chart data
            chart.DataRange           = sheet.Range["B1:B5"];
            chart.SeriesDataFromRange = false;

            //Set position of chart
            chart.LeftColumn  = 1;
            chart.TopRow      = 6;
            chart.RightColumn = 11;
            chart.BottomRow   = 29;


            if (checkBox1.Checked)
            {
                chart.ChartType = ExcelChartType.Cone3DClustered;
            }
            else
            {
                chart.ChartType = ExcelChartType.ConeClustered;
            }

            //Chart title
            chart.ChartTitle            = "Sales by year";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size   = 12;

            chart.PrimaryCategoryAxis.Title            = "Year";
            chart.PrimaryCategoryAxis.Font.IsBold      = true;
            chart.PrimaryCategoryAxis.TitleArea.IsBold = true;

            chart.PrimaryValueAxis.Title                       = "Sales(in Dollars)";
            chart.PrimaryValueAxis.HasMajorGridLines           = false;
            chart.PrimaryValueAxis.MinValue                    = 1000;
            chart.PrimaryValueAxis.TitleArea.IsBold            = true;
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;



            Charts.ChartSerie cs = chart.Series[0];
            cs.CategoryLabels = sheet.Range["A2:A5"];

            chart.Legend.Position = LegendPositionType.Top;
            workbook.SaveToFile("Sample.xls");
            ExcelDocViewer(workbook.FileName);
        }
예제 #4
0
        private void CreateStackedColumnChart(Worksheet sheet, Chart chart)
        {
            //Set region of chart data
            chart.DataRange           = sheet.Range["A1:C5"];
            chart.SeriesDataFromRange = false;

            //Set position of chart
            chart.LeftColumn  = 1;
            chart.TopRow      = 6;
            chart.RightColumn = 11;
            chart.BottomRow   = 29;

            //Chart title
            chart.ChartTitle            = "Sales market by country";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size   = 12;

            chart.PrimaryCategoryAxis.Title                       = "Country";
            chart.PrimaryCategoryAxis.Font.IsBold                 = true;
            chart.PrimaryCategoryAxis.TitleArea.IsBold            = true;
            chart.PrimaryCategoryAxis.TitleArea.TextRotationAngle = 90;


            chart.PrimaryValueAxis.Title             = "Sales(in Dollars)";
            chart.PrimaryValueAxis.HasMajorGridLines = false;
            chart.PrimaryValueAxis.MinValue          = 1000;
            chart.PrimaryValueAxis.TitleArea.IsBold  = true;


            Charts.ChartSerie cs = chart.Series[0];
            cs.Format.Options.IsVaryColor = true;
        }
예제 #5
0
        private void CreateChart(Worksheet sheet, Chart chart)
        {
            //Set region of chart data
            chart.DataRange           = sheet.Range["B2:B5"];
            chart.SeriesDataFromRange = false;

            //Set position of chart
            chart.LeftColumn  = 1;
            chart.TopRow      = 6;
            chart.RightColumn = 9;
            chart.BottomRow   = 25;


            //Chart title
            chart.ChartTitle            = "Sales by year";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size   = 12;


            Charts.ChartSerie cs = chart.Series[0];
            cs.CategoryLabels = sheet.Range["A2:A5"];
            cs.Values         = sheet.Range["B2:B5"];
            cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
        }