public void GetPane(short sheet, ref int x, ref int y, ref int rwTop, ref int columnLeft, ref int activePane) { IExcelWorksheet worksheet = this._workbook.Worksheets[sheet]; ExcelWorksheet.ExcelViewportInfo defaultViewport = worksheet.DefaultViewport; if (defaultViewport != null) { double num = 0.0; double num2 = 0.0; int rowPaneCount = defaultViewport.RowPaneCount; int columnPaneCount = defaultViewport.ColumnPaneCount; if ((rowPaneCount == 2) || (columnPaneCount == 2)) { bool flag = true; bool flag2 = true; if (rowPaneCount == 2) { if (defaultViewport.ActiveRowPane == 1) { flag = false; } if (defaultViewport.PreferredHeight[0] == -1) { y = 0x12; } else { y = defaultViewport.PreferredHeight[0] + 0x12; } num = (Convert.ToDouble((int)y, (IFormatProvider)CultureInfo.InvariantCulture) * 1440.0) / 96.0; y = Convert.ToInt32((double)num, (IFormatProvider)CultureInfo.InvariantCulture); rwTop = defaultViewport.TopRow[1]; } else { y = 0; } if (columnPaneCount == 2) { if (defaultViewport.ActiveColumnPane == 1) { flag2 = false; } if (defaultViewport.PreferredWidth[0] == -1) { x = 0x22; } else { x = defaultViewport.PreferredWidth[0] + 0x22; } num2 = (Convert.ToDouble((int)x, (IFormatProvider)CultureInfo.InvariantCulture) * 1440.0) / 96.0; x = Convert.ToInt32((double)num2, (IFormatProvider)CultureInfo.InvariantCulture); columnLeft = defaultViewport.LeftColumn[1]; } else { x = 0; } if (flag) { if (flag2) { activePane = 3; } else { activePane = 1; } } else if (flag2) { activePane = 2; } else { activePane = 0; } } } }
public bool GetSelectionList(short sheet, List <GcRect> selectionList, ref GcPoint activeCell, ref PaneType paneIndex) { IExcelWorksheet worksheet = this._workbook.Worksheets[sheet]; int frozenRowCount = worksheet.FrozenRowCount; int frozenColumnCount = worksheet.FrozenColumnCount; activeCell.X = worksheet.ActiveColumnIndex; activeCell.Y = worksheet.ActiveRowIndex; ExcelWorksheet.ExcelViewportInfo defaultViewport = worksheet.DefaultViewport; if (defaultViewport != null) { int rowPaneCount = defaultViewport.RowPaneCount; int columnPaneCount = defaultViewport.ColumnPaneCount; if ((paneIndex != PaneType.TopLeft) && ((rowPaneCount > 2) || (columnPaneCount > 2))) { return(false); } if (paneIndex == PaneType.BottomRight) { if (((rowPaneCount <= 1) || (columnPaneCount <= 1)) && ((frozenRowCount <= 0) || (frozenColumnCount <= 0))) { return(false); } } else if (paneIndex == PaneType.TopRight) { if ((columnPaneCount <= 1) && (frozenColumnCount <= 0)) { return(false); } } else if (paneIndex == PaneType.BottomLeft) { if ((rowPaneCount <= 1) && (frozenRowCount <= 0)) { return(false); } } else { int num1 = (int)paneIndex; } if (selectionList != null) { if ((worksheet.Selections != null) && (worksheet.Selections.Count > 0)) { foreach (ISelectionRange range in worksheet.Selections) { if (range.activePaneType == paneIndex) { GcRect rect = new GcRect((range.Column > 0) ? ((double)range.Column) : ((double)0), (range.Row > 0) ? ((double)range.Row) : ((double)0), (range.ColumnSpan > 0) ? ((double)range.ColumnSpan) : ((double)0x4000), (range.RowSpan > 0) ? ((double)range.RowSpan) : ((double)0x100000)); selectionList.Add(rect); } } } else { selectionList.Add(new GcRect(activeCell.X, activeCell.Y, 1.0, 1.0)); } } } return(true); }
public void SetPane(short sheet, int x, int y, int rwTop, int columnLeft, int pnnAct, bool isPanesFrozen) { this._workbook.ActivePaneIndex = pnnAct; IExcelWorksheet worksheet = this._workbook.Worksheets[sheet]; if (isPanesFrozen) { worksheet.FrozenColumnCount = x; worksheet.FrozenRowCount = y; } else { int num = 0; int num2 = 0; if (x > 0) { double num3 = (Convert.ToDouble((int)x, (IFormatProvider)CultureInfo.InvariantCulture) * 96.0) / 1440.0; num3 -= 34.0; num = Convert.ToInt32((double)num3, (IFormatProvider)CultureInfo.InvariantCulture); } if (y > 0) { double num4 = (Convert.ToDouble((int)y, (IFormatProvider)CultureInfo.InvariantCulture) * 96.0) / 1440.0; num4 -= 18.0; num2 = Convert.ToInt32((double)num4, (IFormatProvider)CultureInfo.InvariantCulture); } ExcelWorksheet.ExcelViewportInfo defaultViewport = worksheet.DefaultViewport; switch (pnnAct) { case 0: defaultViewport.ActiveColumnPane = 1; defaultViewport.ActiveRowPane = 1; break; case 1: defaultViewport.ActiveColumnPane = 1; defaultViewport.ActiveRowPane = 0; break; case 2: defaultViewport.ActiveColumnPane = 0; defaultViewport.ActiveRowPane = 1; break; case 3: defaultViewport.ActiveColumnPane = 0; defaultViewport.ActiveRowPane = 0; break; } if (x > 0) { defaultViewport.ColumnPaneCount++; int[] numArray = new int[2]; numArray[1] = columnLeft; defaultViewport.LeftColumn = numArray; defaultViewport.PreferredWidth = new int[] { num, -1 }; } if (y > 0) { defaultViewport.RowPaneCount++; int[] numArray3 = new int[2]; numArray3[1] = rwTop; defaultViewport.TopRow = numArray3; defaultViewport.PreferredHeight = new int[] { num2, -1 }; } } }