private TableAndSelectionLocation TableIntersectsWithSelectionRange(WorksheetRegion tableRegion, SpreadsheetCellRange selectionRegion) { Rect tableRectangle = new Rect(new Point(tableRegion.FirstRow, tableRegion.FirstColumn), new Point(tableRegion.LastRow, tableRegion.LastColumn)); Rect selectionRectangle = new Rect(new Point(selectionRegion.FirstRow, selectionRegion.FirstColumn), new Point(selectionRegion.LastRow, selectionRegion.LastColumn)); if (selectionRectangle.Width == 0 && selectionRectangle.Height == 0) { if (tableRectangle.Contains(selectionRectangle.X, selectionRectangle.Y)) { return(TableAndSelectionLocation.SelectionIsInsideTable); } else { return(TableAndSelectionLocation.NoIntersection); } } if (!tableRectangle.IntersectsWith(selectionRectangle)) { return(TableAndSelectionLocation.NoIntersection); } else if (tableRectangle.Contains(selectionRectangle)) { return(TableAndSelectionLocation.SelectionIsInsideTable); } else { return(TableAndSelectionLocation.PartialIntersection); } }
private static void Sort(int rowCount, Worksheet sheet) { var region = new WorksheetRegion(sheet, 0, 0, rowCount, 3); var table = region.FormatAsTable(true); table.SortSettings.SortConditions.Add(table.Columns[1], new OrderedSortCondition()); }
private void ApplyCellFormat(int CurrentRowNum, string startCol, CellFillPattern cellFillFormat) { string regionName = startCol + (CurrentRowNum + 1).ToString() + ":L" + (CurrentRowNum + 1).ToString(); WorksheetRegion region = ws.GetRegion(regionName); foreach (WorksheetCell wCell in region) { wCell.CellFormat.Fill = cellFillFormat; } }