public static void SaveViewportInfo(Worksheet sheet, CopyMoveCellsInfo cellsInfo, int baseRow, int baseColumn, CopyToOption option) { if ((option & CopyToOption.All) > ((CopyToOption)0)) { int rowCount = cellsInfo.RowCount; int columnCount = cellsInfo.ColumnCount; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { if ((option & CopyToOption.Value) > ((CopyToOption)0)) { cellsInfo.SaveValue(i, j, sheet.GetValue(baseRow + i, baseColumn + j, SheetArea.Cells)); } if (((option & CopyToOption.Value) > ((CopyToOption)0)) || ((option & CopyToOption.Formula) > ((CopyToOption)0))) { cellsInfo.SaveFormula(i, j, sheet.GetFormula(baseRow + i, baseColumn + j)); object[,] arrayFormulas = Excel.GetsArrayFormulas(sheet, baseRow, baseColumn, rowCount, columnCount); cellsInfo.SaveArrayFormula(arrayFormulas); } if ((option & CopyToOption.Sparkline) > ((CopyToOption)0)) { Sparkline sparkline = sheet.GetSparkline(baseRow + i, baseColumn + j); CellRange sparklineDataRange = sheet.Cells[baseRow + i, baseColumn + j].SparklineDataRange; CellRange sparklineDateAxisRange = sheet.Cells[baseRow + i, baseColumn + j].SparklineDateAxisRange; if ((sparkline != null) && (sparklineDataRange != null)) { cellsInfo.SaveSparkline(i, j, new SparklineInfo(sparkline, sparklineDataRange, sparklineDateAxisRange)); } else { cellsInfo.SaveSparkline(i, j, null); } } if ((option & CopyToOption.Style) > ((CopyToOption)0)) { cellsInfo.SaveStyle(i, j, GetStyleObject(sheet, baseRow + i, baseColumn + j, SheetArea.Cells)); } if ((option & CopyToOption.Tag) > ((CopyToOption)0)) { cellsInfo.SaveTag(i, j, sheet.GetTag(baseRow + i, baseColumn + j, SheetArea.Cells)); } } } if ((option & CopyToOption.Span) > ((CopyToOption)0)) { IEnumerator enumerator = sheet.SpanModel.GetEnumerator(baseRow, baseColumn, rowCount, columnCount); while (enumerator.MoveNext()) { cellsInfo.SaveSpan((CellRange)enumerator.Current); } } } }
BaseSparklineView CreateSparkline(Sparkline info) { if (info.SparklineType == SparklineType.Column) { return(new ColumnSparklineView(new ColumnSparklineViewInfo(info))); } if (info.SparklineType == SparklineType.Line) { return(new LineSparklineView(new LineSparklineViewInfo(info))); } return(new WinLossSparklineView(new WinLossSparklineViewInfo(info))); }
static void RearrangeSparklines(Workbook workbook) { #region #RearrangeSparklines Worksheet worksheet = workbook.Worksheets["SparklineExamples"]; workbook.Worksheets.ActiveWorksheet = worksheet; // Create a group of line sparklines. SparklineGroup lineGroup = worksheet.SparklineGroups.Add(worksheet["G4:G7"], worksheet["C4:F4,C5:F5,C6:F6, C7:F7"], SparklineGroupType.Line); // Rearrange sparklines by grouping the second and fourth sparklines together and changing the group type to "Column". Sparkline sparklineG5 = lineGroup.Sparklines[1]; Sparkline sparklineG7 = lineGroup.Sparklines[3]; SparklineGroup columnGroup = worksheet.SparklineGroups.Add(new List <Sparkline> { sparklineG5, sparklineG7 }, SparklineGroupType.Column); #endregion #RearrangeSparklines }
public void CleanUpBeforeDiscard() { if (Children.Count > 1) { while (Children.Count > 1) { Children.RemoveAt(Children.Count - 1); } _customDrawingObjectView = null; if (_sparkInfo != null) { _sparkInfo.SparklineChanged -= new EventHandler(sparkline_SparklineChanged); _sparkInfo = null; } } }
void sparkline_SparklineChanged(object sender, EventArgs e) { Sparkline sparkline = sender as Sparkline; if ((_sparklineView == null) || (_sparklineView.SparklineType != sparkline.SparklineType)) { if (_sparklineView != null) { Children.Remove(_sparklineView); _sparklineView = null; } SynSparklineView(); } else if (_sparklineView != null) { _sparklineView.Update(GetCellSize(), Excel.ZoomFactor); } }
private void InitFlexGrid() { // setup flexgrid _flexGrid.AllowFiltering = true; _flexGrid.AllowFiltering = true; _flexGrid.AllowMerging = AllowMergingEnum.Nodes; _flexGrid.HideGroupedColumns = true; _flexGrid.ShowErrors = true; ColumnCollection columns = _flexGrid.Cols; // setup flexgrid columns columns[0].Width = 22; Column idColumn = columns["ID"]; idColumn.Width = 50; idColumn.AllowEditing = false; // setup combo list IEnumerable <string> products = (from s in _dataSet.Tables["Products"].Rows.Cast <DataRow>() select s) .Select(x => x["Name"].ToString()); columns["Product"].ComboList = string.Join("|", products); // build image map for countries var flagImageMap = new Dictionary <Country, Image>(); foreach (Country country in Enum.GetValues(typeof(Country))) { flagImageMap.Add(country, LoadImage(country.ToString())); } Column countryColumn = columns["Country"]; // assign image map to country column countryColumn.ImageMap = flagImageMap; countryColumn.ImageAndText = true; // build image map for colors var colorImageMap = new Dictionary <DrawColor, Image>(); foreach (DrawColor color in Enum.GetValues(typeof(DrawColor))) { colorImageMap.Add(color, LoadImage(color.ToString())); } Column colorColumn = columns["Color"]; // assign image map to color column colorColumn.ImageMap = colorImageMap; colorColumn.ImageAndText = true; Column priceColumn = columns["Price"]; priceColumn.Format = "C2"; priceColumn.TextAlign = TextAlignEnum.RightCenter; priceColumn.Width = 80; ValidationRuleCollection priceEditorValidation = _flexGrid.Cols["Price"].EditorValidation; // add validation rules priceEditorValidation.Add(new RequiredRule()); priceEditorValidation.Add(new RangeRule() { Minimum = decimal.Zero, Maximum = decimal.MaxValue, ErrorMessage = "Price cannot be negative" }); Column changeColumn = columns["Change"]; changeColumn.Format = "C2"; changeColumn.TextAlign = TextAlignEnum.RightCenter; Column historyColumn = columns["History"]; historyColumn.AllowEditing = false; // setup sparkline for history column historyColumn.ShowSparkline = true; Sparkline historySparkline = historyColumn.Sparkline; historySparkline.ShowLow = true; historySparkline.ShowHigh = true; Column discountColumn = columns["Discount"]; discountColumn.Format = "p0"; discountColumn.AllowEditing = false; discountColumn.Width = 80; Column ratingColumn = columns["Rating"]; ratingColumn.ImageAndText = false; ratingColumn.AllowEditing = false; columns["Active"].Width = 60; Column dateColumn = columns["Date"]; dateColumn.Format = "g"; // creating footers var footerDescription = new FooterDescription(); // price aggregate var priceAggregateDefinition = new AggregateDefinition() { Aggregate = AggregateEnum.Average, Caption = "Average price: ${0:N2}", PropertyName = "Price" }; // discount aggregate var discountAggregateDefinition = new AggregateDefinition { Aggregate = AggregateEnum.Average, Caption = "Average discount: {0:P}", PropertyName = "Discount" }; ObservableCollection <AggregateDefinition> aggregates = footerDescription.Aggregates; aggregates.Add(priceAggregateDefinition); aggregates.Add(discountAggregateDefinition); // add footers Footers footers = _flexGrid.Footers; footers.Descriptions.Add(footerDescription); footers.Fixed = true; // set details _flexGrid.RowDetailProvider = (g, r) => new CustomRowDetail(); // add red style CellStyle redStyle = _flexGrid.Styles.Add("Red"); redStyle.ImageAlign = ImageAlignEnum.LeftCenter; redStyle.ForeColor = Color.Red; // add green style CellStyle greenStyle = _flexGrid.Styles.Add("Green"); greenStyle.ImageAlign = ImageAlignEnum.LeftCenter; greenStyle.ForeColor = Color.Green; // add rating style CellStyle ratingStyle = _flexGrid.Styles.Add("Rating"); ratingStyle.ImageAlign = ImageAlignEnum.RightCenter; }
/// <summary> /// Initializes a new instance of the <see cref="SparklineHtmlBuilder{T}" /> class. /// </summary> /// <param name="component">The Sparkline component.</param> public SparklineHtmlBuilder(Sparkline <T> component) { sparkline = component; }
/// <summary> /// Initializes a new instance of the <see cref="SparklineBuilder{T}"/> class. /// </summary> /// <param name="component">The component.</param> public SparklineBuilder(Sparkline <T> component) : base(component) { }
public SparklineSeriesDefaultsBuilder(Sparkline <TModel> sparkline) { this.sparkline = sparkline; }
//*** CellsPanel.Measure -> RowsLayer.Measure -> RowItem.UpdateChildren -> 行列改变时 CellItem.UpdateChildren -> RowItem.Measure -> CellItem.Measure ***// public void UpdateChildren() { // 刷新绑定的Cell int row = OwnRow.Row; int column = Column; if (CellLayout != null) { row = CellLayout.Row; column = CellLayout.Column; } BindingCell = OwnRow.OwnPanel.CellCache.GetCachedCell(row, column); if (BindingCell == null) { return; } Background = BindingCell.ActualBackground; var excel = Excel; Worksheet sheet = BindingCell.Worksheet; // 迷你图 Sparkline sparkline = sheet.GetSparkline(row, column); if (_sparkInfo != sparkline) { SparkLine = sparkline; SynSparklineView(); } // 收集所有DrawingObject List <DrawingObject> list = new List <DrawingObject>(); DrawingObject[] objArray = sheet.GetDrawingObject(row, column, 1, 1); if ((objArray != null) && (objArray.Length > 0)) { list.AddRange(objArray); } IDrawingObjectProvider drawingObjectProvider = DrawingObjectManager.GetDrawingObjectProvider(excel); if (drawingObjectProvider != null) { DrawingObject[] objArray2 = drawingObjectProvider.GetDrawingObjects(sheet, row, column, 1, 1); if ((objArray2 != null) && (objArray2.Length > 0)) { list.AddRange(objArray2); } } _dataBarObject = null; _iconObject = null; _customDrawingObject = null; if (list.Count > 0) { foreach (DrawingObject obj in list) { if (obj is DataBarDrawingObject bar) { _dataBarObject = bar; } else if (obj is IconDrawingObject icon) { _iconObject = icon; } else if (obj is CustomDrawingObject cust) { _customDrawingObject = cust; } } } bool noBarIcon = SynContitionalView(); bool noCust = SynCustomDrawingObjectView(); if (sparkline == null && noBarIcon && noCust && !string.IsNullOrEmpty(BindingCell.Text)) { _tb.Text = BindingCell.Text; ApplyStyle(); } else { _tb.ClearValue(TextBlock.TextProperty); } SynStrikethroughView(); #if UWP || WASM // 手机上体验不好 if (!excel.IsTouching) { FilterButtonInfo info = excel.GetFilterButtonInfo(row, column, BindingCell.SheetArea); if (info != FilterButtonInfo) { FilterButtonInfo = info; SynFilterButton(); } } #endif }