Пример #1
0
    public void UpdateChart(FarPoint.Win.Spread.FpSpread FpSpread)
    {
        foreach (FarPoint.Win.Spread.SheetView Sheet in FpSpread.Sheets)
        {
            //支持嵌入的图表
            int RowCount    = Sheet.GetLastNonEmptyRow(FarPoint.Win.Spread.NonEmptyItemFlag.Style);
            int ColumnCount = Sheet.GetLastNonEmptyColumn(FarPoint.Win.Spread.NonEmptyItemFlag.Style);
            for (int i = 0; i <= RowCount; i++)
            {
                for (int j = 0; j <= ColumnCount; j++)
                {
                    if (Sheet.Cells[i, j].CellType is ChartCellType)
                    {
                        ChartCellType ChartType = Sheet.Cells[i, j].CellType as ChartCellType;
                        Rectangle     r         = FpSpread.GetCellRectangle(0, 0, i, j);
                        ChartType.ChartSize   = r.Size;
                        ChartType.ActiveSheet = Sheet;
                        ChartType.UpdateChart();
                    }
                }
            }

            //支持浮动的图表
            foreach (IElement Element in Sheet.DrawingContainer.ContainedObjects)
            {
                if (Element is ChartShape)
                {
                    ChartShape Shape = Element as ChartShape;
                    Shape.ActiveSheet = Sheet;
                    Shape.Locked      = false;
                    Shape.UpdateChart();
                }
            }
        }
    }