/// <summary> /// 粘贴 /// </summary> private void Paste() { Cell cell = ActiveSheet.ActiveCell; //JZCellProperty p = cell.Tag as JZCellProperty; if (cell.Locked == true) { return; } ActiveSheet.ClipboardPaste(ClipboardPasteOptions.AsString); }
public void DeleteColumns() { List <CellRange> Ranges = Selections; if (Ranges.Count > 0) { ActiveSheet.Columns.Remove(Ranges[0].Column, Ranges[0].ColumnCount); } ActiveSheet.RaisePropertyChanged("ColumnCount"); }
public void DeleteRows() { List <CellRange> Ranges = Selections; if (Ranges.Count > 0) { ActiveSheet.Rows.Remove(Ranges[0].Row, Ranges[0].RowCount); } ActiveSheet.RaisePropertyChanged("RowCount"); }
private CellRange getActiveCell(int row, int col) { CellRange cr = ActiveSheet.GetSpanCell(row, col); if (cr == null) { Cell Cell = ActiveSheet.Cells[row, col]; cr = new CellRange(Cell.Row.Index, Cell.Column.Index, Cell.RowSpan, Cell.ColumnSpan); } return(cr); }
public void InsertColumns() { if (Selections.Count > 0) { if (Selections[0].ColumnCount < 10) { ActiveSheet.AddColumns(ActiveSheet.ActiveColumnIndex, Selections[0].ColumnCount); } else { ActiveSheet.AddColumns(ActiveSheet.ActiveColumnIndex, 10); } } ActiveSheet.RaisePropertyChanged("ColumnCount"); }
public void InsertRows() { if (Selections.Count > 0) { if (Selections[0].RowCount < 10) { ActiveSheet.AddRows(ActiveSheet.ActiveRowIndex, Selections[0].RowCount); } else { ActiveSheet.AddRows(ActiveSheet.ActiveRowIndex, 10); } } ActiveSheet.RaisePropertyChanged("RowCount"); }
//Return active sheet private int getActiveSheet(ActiveSheet e) { if (e == ActiveSheet.Kisi) { return(1); } else if (e == ActiveSheet.Sehir) { return(2); } else if (e == ActiveSheet.Ilce) { return(3); } else { return(0); } }
//Combobox selection and filling the Grid private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { //Show the selected UserControl and hide the others. foreach (Control u in this.Controls) { if (u.Name == selectCombobox.SelectedItem + "Control") { u.Visible = true; u.Location = new Point(400, 0); u.BringToFront(); } else if (u is UserControl) { u.Visible = false; } } //Fill the grid with selected item try { BLL bll = new BLL(); dataGridView.DataSource = bll.Get(selectCombobox.SelectedItem.ToString()); } catch { MessageBox.Show("An error occured."); } //Determine active sheet if (selectCombobox.SelectedItem.ToString() == "Kisi") { activeSheet = ActiveSheet.Kisi; } else if (selectCombobox.SelectedItem.ToString() == "Sehir") { activeSheet = ActiveSheet.Sehir; } else if (selectCombobox.SelectedItem.ToString() == "Ilce") { activeSheet = ActiveSheet.Ilce; } }
void SubMenuItem_1_Click(object sender, EventArgs e) { Object value = null; ToolStripMenuItem MenuItem = sender as ToolStripMenuItem; if (MenuItem != null) { switch (MenuItem.Text) { case "图表": FloatElement Element = new FloatElement(); ActiveSheet.AddShape(Element); Element.setName(string.Format("图表_{0}", ActiveSheet.DrawingContainer.ContainedObjects.Count)); value = new ChartPainter(); Element.setValue(value); Rectangle RowHeaderRectangle = FpSpread.GetRowHeaderRectangle(0); Rectangle ColumnHeaderRectangle = FpSpread.GetColumnHeaderRectangle(0); Point point = new Point(Element.Left + RowHeaderRectangle.Width, Element.Top + ColumnHeaderRectangle.Height); CellRange range = FpSpread.GetCellFromPixel(0, 0, point.X, point.Y); Rectangle r = FpSpread.GetCellRectangle(0, 0, range.Row, range.Column); Element.setRow(range.Row); Element.setColumn(range.Column); Element.setLeftDistance(point.X - r.Left); Element.setTopDistance(point.Y - r.Top); break; } if (value == null) { String msg = "当前版本不支持" + MenuItem.Text + "报表浮动元素。"; MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
void AutoFitColumnInternal(int columnIndex, bool supportUndo, bool isRowHeader) { List <ColumnAutoFitExtent> list = new List <ColumnAutoFitExtent>(); if (ActiveSheet.IsSelected(-1, columnIndex)) { foreach (CellRange range in ActiveSheet.Selections) { if (range.Row == -1) { int num = (range.Column == -1) ? 0 : range.Column; int num2 = (range.Column == -1) ? ActiveSheet.ColumnCount : range.ColumnCount; for (int i = num; i < (num + num2); i++) { list.Add(new ColumnAutoFitExtent(i)); } } } } else { list.Add(new ColumnAutoFitExtent(columnIndex)); } ColumnAutoFitExtent[] columns = new ColumnAutoFitExtent[list.Count]; list.CopyTo(columns); ColumnAutoFitUndoAction command = new ColumnAutoFitUndoAction(ActiveSheet, columns, isRowHeader); if (supportUndo) { DoCommand(command); } else { command.Execute(this); } }
void AutoFitRowInternal(int rowIndex, bool supportUndo, bool isColumnHeader) { List <RowAutoFitExtent> list = new List <RowAutoFitExtent>(); if (ActiveSheet.IsSelected(rowIndex, -1)) { foreach (CellRange range in ActiveSheet.Selections) { if (range.Column == -1) { int num = (range.Row == -1) ? 0 : range.Row; int num2 = (range.Row == -1) ? ActiveSheet.RowCount : range.RowCount; for (int i = num; i < (num + num2); i++) { list.Add(new RowAutoFitExtent(i)); } } } } else { list.Add(new RowAutoFitExtent(rowIndex)); } RowAutoFitExtent[] rows = new RowAutoFitExtent[list.Count]; list.CopyTo(rows); RowAutoFitUndoAction command = new RowAutoFitUndoAction(ActiveSheet, rows, isColumnHeader); if (supportUndo) { DoCommand(command); } else { command.Execute(this); } }
/// <summary> /// Constructs an Excel application /// </summary> public Excel() { _activeSheet = new ActiveSheet(); Globals.ThisAddIn.Application.WorkbookActivate += (wb) => _workbookOpened(); _worksheetProperties = new WorksheetProperties(this); }
public void PasteData() { ActiveSheet.ClipboardPaste(); }
public void Redo() { ActiveSheet.ClipboardPaste(); }
public void ShearData() { ActiveSheet.ClipboardCut(); }
public void CopyData() { ActiveSheet.ClipboardCopy(); }
/// <summary> /// 复制 /// </summary> private void Copy() { ActiveSheet.ClipboardCopy(); }
/// <summary> /// 剪切 /// </summary> private void Cut() { ActiveSheet.ClipboardCut(); }
void DoResizeFloatingObjects() { SuspendFloatingObjectsInvalidate(); if ((_movingResizingFloatingObjects != null) && (_movingResizingFloatingObjects.Count > 0)) { int activeRowViewportIndex = GetActiveRowViewportIndex(); int activeColumnViewportIndex = GetActiveColumnViewportIndex(); Rect[] floatingObjectsResizingRects = GetFloatingObjectsResizingRects(activeRowViewportIndex, activeColumnViewportIndex); List <string> list = new List <string>(); List <Rect> list2 = new List <Rect>(); for (int i = 0; (i < _movingResizingFloatingObjects.Count) && (i < floatingObjectsResizingRects.Length); i++) { FloatingObject obj2 = _movingResizingFloatingObjects[i]; Rect rect = new Rect(floatingObjectsResizingRects[i].X, floatingObjectsResizingRects[i].Y, floatingObjectsResizingRects[i].Width, floatingObjectsResizingRects[i].Height); RowLayout viewportRowLayoutNearY = GetViewportRowLayoutNearY(activeRowViewportIndex, rect.Y); if (viewportRowLayoutNearY == null) { viewportRowLayoutNearY = GetViewportRowLayoutNearY(-1, rect.Y); } int row = 0; if (viewportRowLayoutNearY != null) { row = viewportRowLayoutNearY.Row; } double num5 = rect.Y - viewportRowLayoutNearY.Y; double y = 0.0; for (int j = 0; j < row; j++) { double num8 = Math.Ceiling((double)(ActiveSheet.GetActualRowHeight(j, SheetArea.Cells) * ZoomFactor)); y += num8; } y += num5; ColumnLayout viewportColumnLayoutNearX = GetViewportColumnLayoutNearX(activeColumnViewportIndex, rect.X); if (viewportColumnLayoutNearX == null) { viewportColumnLayoutNearX = GetViewportColumnLayoutNearX(-1, rect.X); } double column = 0.0; if (viewportColumnLayoutNearX != null) { column = viewportColumnLayoutNearX.Column; } double num10 = rect.X - viewportColumnLayoutNearX.X; double x = 0.0; for (int k = 0; k < column; k++) { double num13 = Math.Ceiling((double)(ActiveSheet.GetActualColumnWidth(k, SheetArea.Cells) * ZoomFactor)); x += num13; } x += num10; x = Math.Floor((double)(x / ((double)ZoomFactor))); y = Math.Floor((double)(y / ((double)ZoomFactor))); double width = Math.Floor((double)(rect.Width / ((double)ZoomFactor))); double height = Math.Floor((double)(rect.Height / ((double)ZoomFactor))); list.Add(obj2.Name); list2.Add(new Rect(x, y, width, height)); } ResizeFloatingObjectExtent extent = new ResizeFloatingObjectExtent(list.ToArray(), list2.ToArray()); DoCommand(new ResizeFloatingObjectUndoAction(ActiveSheet, extent)); } ResumeFloatingObjectsInvalidate(); }
void EndTouchRowResizing() { IsWorking = false; IsTouchResizingRows = false; HitTestInformation savedHitTestInformation = GetHitInfo(); if ((savedHitTestInformation.HitPoint.Y == MousePosition.Y) || !_DoTouchResizing) { TooltipHelper.CloseTooltip(); _resizingTracker.Visibility = Visibility.Collapsed; } else { RowLayout viewportResizingRowLayoutFromYForTouch = null; switch (savedHitTestInformation.HitTestType) { case HitTestType.Corner: viewportResizingRowLayoutFromYForTouch = GetColumnHeaderRowLayoutModel().FindRow(savedHitTestInformation.HeaderInfo.ResizingRow); if (viewportResizingRowLayoutFromYForTouch != null) { double num6 = (_resizingTracker.Y1 - viewportResizingRowLayoutFromYForTouch.Y) - viewportResizingRowLayoutFromYForTouch.Height; int row = viewportResizingRowLayoutFromYForTouch.Row; double size = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.ColumnHeader.Rows[row].ActualHeight + (num6 / ((double)ZoomFactor))))); RowResizeExtent[] rows = new RowResizeExtent[] { new RowResizeExtent(row, row) }; RowResizeUndoAction command = new RowResizeUndoAction(ActiveSheet, rows, size, true); DoCommand(command); } break; case HitTestType.RowHeader: { viewportResizingRowLayoutFromYForTouch = GetViewportResizingRowLayoutFromYForTouch(savedHitTestInformation.RowViewportIndex, savedHitTestInformation.HitPoint.Y); bool flag = false; if ((viewportResizingRowLayoutFromYForTouch == null) && (savedHitTestInformation.RowViewportIndex == 0)) { viewportResizingRowLayoutFromYForTouch = GetViewportResizingRowLayoutFromYForTouch(-1, savedHitTestInformation.HitPoint.Y); } if (((viewportResizingRowLayoutFromYForTouch == null) && (savedHitTestInformation.HeaderInfo != null)) && (savedHitTestInformation.HeaderInfo.ResizingRow >= 0)) { viewportResizingRowLayoutFromYForTouch = GetViewportRowLayoutModel(savedHitTestInformation.RowViewportIndex).FindRow(savedHitTestInformation.HeaderInfo.ResizingRow); } if ((viewportResizingRowLayoutFromYForTouch == null) && ((savedHitTestInformation.RowViewportIndex == -1) || (savedHitTestInformation.RowViewportIndex == 0))) { viewportResizingRowLayoutFromYForTouch = GetColumnHeaderResizingRowLayoutFromYForTouch(savedHitTestInformation.HitPoint.Y); flag = true; } if (viewportResizingRowLayoutFromYForTouch != null) { double num = (_resizingTracker.Y1 - viewportResizingRowLayoutFromYForTouch.Y) - viewportResizingRowLayoutFromYForTouch.Height; int firstRow = viewportResizingRowLayoutFromYForTouch.Row; double num3 = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.Rows[firstRow].ActualHeight + (num / ((double)ZoomFactor))))); if (flag) { RowResizeExtent[] extentArray2 = new RowResizeExtent[] { new RowResizeExtent(firstRow, firstRow) }; RowResizeUndoAction action2 = new RowResizeUndoAction(ActiveSheet, extentArray2, num3, true); DoCommand(action2); break; } List <RowResizeExtent> list = new List <RowResizeExtent>(); if (ActiveSheet.IsSelected(firstRow, -1)) { foreach (CellRange range in ActiveSheet.Selections) { if (range.Column == -1) { int num4 = (range.Row == -1) ? 0 : range.Row; int num5 = ((range.Row == -1) && (range.RowCount == -1)) ? ActiveSheet.RowCount : range.RowCount; list.Add(new RowResizeExtent(num4, (num4 + num5) - 1)); } } } else { list.Add(new RowResizeExtent(firstRow, firstRow)); } RowResizeExtent[] extentArray = new RowResizeExtent[list.Count]; list.CopyTo(extentArray); RowResizeUndoAction action = new RowResizeUndoAction(ActiveSheet, extentArray, num3, false); DoCommand(action); } break; } } TooltipHelper.CloseTooltip(); _resizingTracker.Visibility = Visibility.Collapsed; _DoTouchResizing = false; } }
void EndTouchColumnResizing() { IsWorking = false; IsTouchResizingColumns = false; HitTestInformation savedHitTestInformation = GetHitInfo(); if ((savedHitTestInformation.HitPoint.X == MousePosition.X) || !_DoTouchResizing) { TooltipHelper.CloseTooltip(); _resizingTracker.Visibility = Visibility.Collapsed; } else { ColumnLayout viewportResizingColumnLayoutFromXForTouch; switch (savedHitTestInformation.HitTestType) { case HitTestType.Corner: viewportResizingColumnLayoutFromXForTouch = GetRowHeaderColumnLayoutModel().FindColumn(savedHitTestInformation.HeaderInfo.ResizingColumn); if (viewportResizingColumnLayoutFromXForTouch != null) { double num6 = (_resizingTracker.X1 - viewportResizingColumnLayoutFromXForTouch.X) - viewportResizingColumnLayoutFromXForTouch.Width; int column = viewportResizingColumnLayoutFromXForTouch.Column; double size = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.RowHeader.Columns[column].ActualWidth + (num6 / ((double)ZoomFactor))))); ColumnResizeExtent[] columns = new ColumnResizeExtent[] { new ColumnResizeExtent(column, column) }; ColumnResizeUndoAction command = new ColumnResizeUndoAction(ActiveSheet, columns, size, true); DoCommand(command); } break; case HitTestType.ColumnHeader: { viewportResizingColumnLayoutFromXForTouch = GetViewportResizingColumnLayoutFromXForTouch(savedHitTestInformation.ColumnViewportIndex, savedHitTestInformation.HitPoint.X); bool flag = false; if (viewportResizingColumnLayoutFromXForTouch == null) { viewportResizingColumnLayoutFromXForTouch = GetViewportColumnLayoutModel(savedHitTestInformation.ColumnViewportIndex).FindColumn(savedHitTestInformation.HeaderInfo.ResizingColumn); if ((viewportResizingColumnLayoutFromXForTouch == null) && (savedHitTestInformation.ColumnViewportIndex == 0)) { viewportResizingColumnLayoutFromXForTouch = GetViewportResizingColumnLayoutFromXForTouch(-1, savedHitTestInformation.HitPoint.X); } if ((viewportResizingColumnLayoutFromXForTouch == null) && ((savedHitTestInformation.ColumnViewportIndex == 0) || (savedHitTestInformation.ColumnViewportIndex == -1))) { viewportResizingColumnLayoutFromXForTouch = GetRowHeaderResizingColumnLayoutFromXForTouch(savedHitTestInformation.HitPoint.X); flag = true; } } if (viewportResizingColumnLayoutFromXForTouch != null) { double num = (_resizingTracker.X1 - viewportResizingColumnLayoutFromXForTouch.X) - viewportResizingColumnLayoutFromXForTouch.Width; int num2 = viewportResizingColumnLayoutFromXForTouch.Column; double num3 = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.Columns[num2].ActualWidth + (num / ((double)ZoomFactor))))); if (!flag) { List <ColumnResizeExtent> list = new List <ColumnResizeExtent>(); if (ActiveSheet.IsSelected(-1, num2)) { foreach (CellRange range in ActiveSheet.Selections) { if (range.Row == -1) { int firstColumn = (range.Column == -1) ? 0 : range.Column; int num5 = ((range.Column == -1) && (range.ColumnCount == -1)) ? ActiveSheet.ColumnCount : range.ColumnCount; list.Add(new ColumnResizeExtent(firstColumn, (firstColumn + num5) - 1)); } } } else { list.Add(new ColumnResizeExtent(num2, num2)); } ColumnResizeExtent[] extentArray = new ColumnResizeExtent[list.Count]; list.CopyTo(extentArray); ColumnResizeUndoAction action = new ColumnResizeUndoAction(ActiveSheet, extentArray, num3, false); DoCommand(action); } else { ColumnResizeExtent[] extentArray2 = new ColumnResizeExtent[] { new ColumnResizeExtent(num2, num2) }; ColumnResizeUndoAction action2 = new ColumnResizeUndoAction(ActiveSheet, extentArray2, num3, true); DoCommand(action2); } } break; } } TooltipHelper.CloseTooltip(); _resizingTracker.Visibility = Visibility.Collapsed; _DoTouchResizing = false; } }
public bool ContainsRow(int row) { return(ActiveSheet.ContainsRow(row)); }