예제 #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var worksheet = this.grid.CurrentWorksheet;

            // データ
            worksheet["A2"] = new object[, ] {
                { null, 2008, 2009, 2010, 2011, 2012 },
                { "札幌", 3, 2, 4, 2, 6 },
                { "名古屋", 7, 5, 3, 6, 4 },
                { "東京", 13, 10, 9, 10, 9 },
                { "合計", "=SUM(B3:B5)", "=SUM(C3:C5)", "=SUM(D3:D5)", "=SUM(E3:E5)", "=SUM(F3:F5)" },
            };

            // 範囲を定義
            var dataRange          = worksheet.Ranges["B3:F5"];
            var serialNamesRange   = worksheet.Ranges["A3:A6"];
            var categoryNamesRange = worksheet.Ranges["B2:F2"];

            // 範囲を強調
            worksheet.AddHighlightRange(categoryNamesRange);
            worksheet.AddHighlightRange(serialNamesRange);
            worksheet.AddHighlightRange(dataRange);

            var c1 = new Chart.LineChart
            {
                // 位置
                Location = new Graphics.Point(220, 160),

                // サイズ
                Size = new Graphics.Size(400, 260),

                // グラフタイトル
                Title = "折れ線グラフ",

                // データソース
                DataSource = new WorksheetChartDataSource(worksheet          // ワークシートインスタンス
                                                          , serialNamesRange // データ名の範囲
                                                          , dataRange        // データの範囲
                                                          )
                {
                    CategoryNameRange = categoryNamesRange,                       // グラフの目盛り
                }
            };

            // グラフオブジェクトをワークシートに追加
            worksheet.FloatingObjects.Add(c1);
        }
예제 #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var worksheet = this.grid.CurrentWorksheet;

            worksheet["A2"] = new object[, ] {
                { null, 2008, 2009, 2010, 2011, 2012 },
                { "City 1", 3, 2, 4, 2, 6 },
                { "City 2", 7, 5, 3, 6, 4 },
                { "City 3", 13, 10, 9, 10, 9 },
                { "Total", "=SUM(B3:B5)", "=SUM(C3:C5)", "=SUM(D3:D5)", "=SUM(E3:E5)", "=SUM(F3:F5)" },
            };

            var dataRange          = worksheet.Ranges["B3:F5"];
            var serialNamesRange   = worksheet.Ranges["A3:A6"];
            var categoryNamesRange = worksheet.Ranges["B2:F2"];

            worksheet.AddHighlightRange(categoryNamesRange);
            worksheet.AddHighlightRange(serialNamesRange);
            worksheet.AddHighlightRange(dataRange);

            var c1 = new Chart.LineChart
            {
                Location = new Graphics.Point(220, 160),
                Size     = new Graphics.Size(400, 260),

                Title = "Line Chart Sample",

                // Specify data source.
                // Data source is created from serial data and names for every serial data.
                DataSource = new WorksheetChartDataSource(worksheet, serialNamesRange, dataRange)
                {
                    CategoryNameRange = categoryNamesRange,
                }
            };

            worksheet.FloatingObjects.Add(c1);
        }