9using System.Collections.Generic;
12using System.Text.RegularExpressions;
26 public class Worksheet
53#pragma warning disable CA1805
55#pragma warning restore CA1805
59#pragma warning disable CA1805
61#pragma warning restore CA1805
65#pragma warning disable CA1805
67#pragma warning restore CA1805
79#pragma warning disable CA1805
81#pragma warning restore CA1805
89#pragma warning disable CA1805
91#pragma warning restore CA1805
104 [Obsolete(
"Use MaxZoomFactor instead.")]
189 #region privateFields
190 private Style activeStyle;
191 private Range? autoFilterRange;
192 private readonly Dictionary<CellKey, Cell> cells;
193 private readonly StringKeyedCellView cellsStringView;
194 private readonly Dictionary<int, Column> columns;
195 private string sheetName;
196 private int currentRowNumber;
197 private int currentColumnNumber;
198 private float defaultRowHeight;
199 private float defaultColumnWidth;
200 private readonly Dictionary<int, float> rowHeights;
201 private readonly Dictionary<int, bool> hiddenRows;
202 private readonly Dictionary<string, Range> mergedCells;
203 private readonly List<SheetProtectionValue> sheetProtectionValues;
204 private bool useActiveStyle;
207 private IPassword sheetProtectionPassword;
208 private List<Range> selectedCells;
209 private bool? freezeSplitPanes;
210 private float? paneSplitLeftWidth;
211 private float? paneSplitTopHeight;
212 private Address? paneSplitTopLeftCell;
213 private Address? paneSplitAddress;
217 private Dictionary<SheetViewType, int> zoomFactor;
226 get {
return autoFilterRange; }
233 public IReadOnlyDictionary<string, Cell>
Cells
235 get {
return cellsStringView; }
244 get {
return cells.Values; }
252 get {
return columns; }
266 get {
return defaultColumnWidth; }
273 defaultColumnWidth = value;
283 get {
return defaultRowHeight; }
290 defaultRowHeight = value;
300 get {
return hiddenRows; }
308 get {
return rowHeights; }
316 get {
return mergedCells; }
324 get {
return selectedCells; }
337 throw new FormatException(
"The ID " + value +
" is invalid. Worksheet IDs must be >0");
348 get {
return sheetName; }
358 get {
return sheetProtectionPassword; }
359 internal set { sheetProtectionPassword = value; }
367 get {
return sheetProtectionValues; }
380 get {
return workbookReference; }
383 workbookReference = value;
386 workbookReference.ValidateWorksheets();
398 get {
return hidden; }
402 if (value && workbookReference !=
null)
404 workbookReference.ValidateWorksheets();
419 get {
return paneSplitTopHeight; }
432 get {
return paneSplitLeftWidth; }
441 get {
return freezeSplitPanes; }
451 get {
return paneSplitTopLeftCell; }
463 get {
return paneSplitAddress; }
473 get {
return activePane; }
481 get {
return activeStyle; }
528 return zoomFactor[viewType];
546 internal FeatureSet Features {
get; } =
new FeatureSet() { };
558 cells =
new Dictionary<CellKey, Cell>(1000);
559 cellsStringView =
new StringKeyedCellView(cells);
560 currentRowNumber = 0;
561 currentColumnNumber = 0;
564 rowHeights =
new Dictionary<int, float>();
565 mergedCells =
new Dictionary<string, Range>();
566 selectedCells =
new List<Range>();
567 sheetProtectionValues =
new List<SheetProtectionValue>();
568 hiddenRows =
new Dictionary<int, bool>();
569 columns =
new Dictionary<int, Column>();
571 workbookReference =
null;
573 zoomFactor =
new Dictionary<SheetViewType, int>
604 workbookReference = reference;
609 #region methods_AddNextCell
621 AddNextCell(CastValue(value, currentColumnNumber, currentRowNumber),
true,
null);
637 AddNextCell(CastValue(value, currentColumnNumber, currentRowNumber),
true, style);
653 if (style !=
null || (activeStyle !=
null && useActiveStyle))
655 if (cell.
CellStyle ==
null && useActiveStyle)
659 else if (cell.
CellStyle ==
null && style !=
null)
663 else if (cell.
CellStyle !=
null && useActiveStyle)
666 mixedStyle.
Append(activeStyle);
669 else if (cell.
CellStyle !=
null && style !=
null)
677 if (cells.TryGetValue(cellKey, out Cell previousCell))
679 previousCell.UnbindFeatures();
681 cells[cellKey] = cell;
682 cell.BindFeatures(Features);
687 currentColumnNumber++;
702 currentColumnNumber = cell.ColumnNumber + 1;
708 currentRowNumber = cell.RowNumber + 1;
724 private static Cell CastValue(
object value,
int column,
int row)
727 if (value !=
null && value.GetType() == typeof(Cell))
730 c.CellAddress2 =
new Address(column, row);
734 c =
new Cell(value, Cell.CellType.Default, column, row);
742 #region methods_AddCell
754 public void AddCell(
object value,
int columnNumber,
int rowNumber)
756 AddNextCell(CastValue(value, columnNumber, rowNumber),
false,
null);
771 public void AddCell(
object value,
int columnNumber,
int rowNumber,
Style style)
773 AddNextCell(CastValue(value, columnNumber, rowNumber),
false, style);
787 public void AddCell(
object value,
string address)
812 AddCell(value, column, row, style);
817 #region methods_AddCellFormula
907 #region methods_AddCellReference
925 if (definedName ==
null)
927 throw new WorksheetException(
"The defined name to set as cell reference must not be null.");
930 Range? arrayRange = c.SetReference(definedName, cachedValue);
931 if (arrayRange.HasValue)
933 c.Formula.FormulaRange = arrayRange.Value.
ToString();
936 List<Address> list =
new List<Address>();
937 list.Add(
new Address(columnNumber, rowNumber));
938 if (arrayRange.HasValue)
940 IReadOnlyList<Address> addedCells = AddDefinedNameArrayCells(c, arrayRange.Value,
null);
941 list.AddRange(addedCells);
963 if (definedName ==
null)
965 throw new WorksheetException(
"The defined name to set as cell reference must not be null.");
968 Range? arrayRange = c.SetReference(definedName, cachedValue);
969 if (arrayRange.HasValue)
971 c.Formula.FormulaRange = arrayRange.Value.
ToString();
974 List<Address> list =
new List<Address>();
975 list.Add(
new Address(columnNumber, rowNumber));
976 if (arrayRange.HasValue)
978 IReadOnlyList<Address> addedCells = AddDefinedNameArrayCells(c, arrayRange.Value, style);
979 list.AddRange(addedCells);
1035 internal IReadOnlyList<Address> AddDefinedNameArrayCells(
Cell masterCell,
Range arrayRange,
Style style)
1038 List<Address> addedAddresses =
new List<Address>();
1039 foreach (
Address address
in addresses)
1046 arrayRefCell.Formula.MasterCellAddress = masterCell.
CellAddress;
1050 addedAddresses.Add(address);
1052 return addedAddresses;
1057 #region methods_AddCellRange
1071 AddCellRangeInternal(values, startAddress, endAddress,
null);
1088 AddCellRangeInternal(values, startAddress, endAddress, style);
1166 private void AddCellRangeInternal<T>(IReadOnlyList<T> values,
Address startAddress,
Address endAddress,
Style style)
1170 throw new RangeException(
"The passed value list cannot be null");
1172 List<Address> addresses =
Cell.
GetCellRange(startAddress, endAddress) as List<Address>;
1173 if (values.Count != addresses.Count)
1175 throw new RangeException(
"The number of passed values (" + values.Count +
") differs from the number of cells within the range (" + addresses.Count +
")");
1177 List<Cell> list = Cell.ConvertArray(values) as List<Cell>;
1178 int len = values.Count;
1179 for (
int i = 0; i < len; i++)
1181 list[i].RowNumber = addresses[i].Row;
1182 list[i].ColumnNumber = addresses[i].Column;
1188 #region methods_RemoveCell
1198 CellKey key =
new CellKey(columnNumber, rowNumber);
1199 cells.TryGetValue(key, out
Cell cell);
1202 cell.UnbindFeatures();
1204 return cells.Remove(key);
1223 #region methods_setStyle
1235 foreach (
Address address
in addresses)
1237 if (cells.TryGetValue(
new CellKey(address.
Column, address.
Row), out
Cell existing))
1241 existing.RemoveStyle();
1245 existing.SetStyle(style);
1306 throw new FormatException(
"The passed address'" + addressExpression +
"' is neither a cell address, nor a range");
1312 #region boundaryFunctions
1321 return GetBoundaryNumber(
false,
true);
1332 return GetBoundaryDataNumber(
false,
true,
true);
1343 return GetBoundaryNumber(
true,
true);
1354 return GetBoundaryDataNumber(
true,
true,
true);
1366 return GetBoundaryNumber(
false,
false);
1377 return GetBoundaryDataNumber(
false,
false,
true);
1389 return GetBoundaryNumber(
true,
false);
1401 return GetBoundaryDataNumber(
true,
false,
true);
1416 if (lastRow < 0 || lastColumn < 0)
1420 return new Address(lastColumn, lastRow);
1434 if (lastRow < 0 || lastColumn < 0)
1438 return new Address(lastColumn, lastRow);
1451 if (firstRow < 0 || firstColumn < 0)
1455 return new Address(firstColumn, firstRow);
1468 if (firstRow < 0 || firstColumn < 0)
1472 return new Address(firstColumn, firstRow);
1482 private int GetBoundaryDataNumber(
bool row,
bool min,
bool ignoreEmpty)
1484 if (cells.Count == 0)
1492 return cells.Values.Min(x => x.RowNumber);
1496 return cells.Values.Max(x => x.RowNumber);
1500 return cells.Values.Min(x => x.ColumnNumber);
1504 return cells.Values.Max(x => x.ColumnNumber);
1507 List<Cell> nonEmptyCells = cells.Values.Where(x => x.Value !=
null && x.Value.ToString() !=
string.Empty).ToList();
1508 if (nonEmptyCells.Count == 0)
1514 return nonEmptyCells.Min(x => x.RowNumber);
1518 return nonEmptyCells.Max(x => x.RowNumber);
1522 return nonEmptyCells.Min(x => x.ColumnNumber);
1526 return nonEmptyCells.Max(x => x.ColumnNumber);
1536 private int GetBoundaryNumber(
bool row,
bool min)
1538 int cellBoundary = GetBoundaryDataNumber(row, min,
false);
1541 int heightBoundary = -1;
1542 if (rowHeights.Count > 0)
1546 int hiddenBoundary = -1;
1547 if (hiddenRows.Count > 0)
1551 return min ? GetMinRow(cellBoundary, heightBoundary, hiddenBoundary) : GetMaxRow(cellBoundary, heightBoundary, hiddenBoundary);
1555 int columnDefBoundary = -1;
1556 if (columns.Count > 0)
1558 columnDefBoundary = min ?
Columns.Min(x => x.Key) :
Columns.Max(x => x.Key);
1562 return cellBoundary >= 0 && cellBoundary < columnDefBoundary ? cellBoundary : columnDefBoundary;
1566 return cellBoundary >= 0 && cellBoundary > columnDefBoundary ? cellBoundary : columnDefBoundary;
1578 private static int GetMaxRow(
int cellBoundary,
int heightBoundary,
int hiddenBoundary)
1581 if (cellBoundary >= 0)
1583 highest = cellBoundary;
1585 if (heightBoundary >= 0 && heightBoundary > highest)
1587 highest = heightBoundary;
1589 if (hiddenBoundary >= 0 && hiddenBoundary > highest)
1591 highest = hiddenBoundary;
1603 private static int GetMinRow(
int cellBoundary,
int heightBoundary,
int hiddenBoundary)
1605 int lowest =
int.MaxValue;
1606 if (cellBoundary >= 0)
1608 lowest = cellBoundary;
1610 if (heightBoundary >= 0 && heightBoundary < lowest)
1612 lowest = heightBoundary;
1614 if (hiddenBoundary >= 0 && hiddenBoundary < lowest)
1616 lowest = hiddenBoundary;
1618 return lowest == int.MaxValue ? -1 : lowest;
1622 #region Insert-Search-Replace
1635 var upperRow = this.
GetRow(rowNumber);
1638 var cellsToChange = cells.Values.Where(c => c.
CellAddress2.
Row > rowNumber).ToList();
1641 List<Cell> newCells =
new List<Cell>();
1642 foreach (
Cell cell
in cellsToChange)
1652 newCells.Add(newCell);
1653 cells.Remove(
new CellKey(col, row));
1657 foreach (
Cell cell
in upperRow)
1659 for (
int i = 0; i < numberOfNewRows; i++)
1667 cells[
new CellKey(newAddress.
Column, newAddress.
Row)] = newCell;
1672 foreach (
Cell newCell
in newCells)
1688 var leftColumn = this.
GetColumn(columnNumber);
1689 var cellsToChange = cells.Values.Where(c => c.
CellAddress2.
Column > columnNumber).ToList();
1691 List<Cell> newCells =
new List<Cell>();
1692 foreach (
Cell cell
in cellsToChange)
1702 newCells.Add(newCell);
1703 cells.Remove(
new CellKey(col, row));
1707 foreach (
Cell cell
in leftColumn)
1709 for (
int i = 0; i < numberOfNewColumns; i++)
1717 cells[
new CellKey(newAddress.
Column, newAddress.
Row)] = newCell;
1722 foreach (
Cell newCell
in newCells)
1735 return cells.Values.FirstOrDefault(c => Equals(c.
Value, searchValue));
1746 return cells.Values.FirstOrDefault(c => c !=
null && (c.
Value ==
null || predicate(c)));
1756 return cells.Values.Where(c => Equals(c.
Value, searchValue)).ToList();
1769 foreach (var cell
in foundCells)
1771 cell.Value = newValue;
1778 #region common_methods
1787 if (!sheetProtectionValues.Contains(typeOfProtection))
1793 sheetProtectionValues.Add(typeOfProtection);
1805 SetColumnHiddenState(columnNumber,
true);
1816 SetColumnHiddenState(columnNumber,
true);
1826 SetRowHiddenState(rowNumber,
true);
1834 useActiveStyle =
false;
1846 if (!cells.TryGetValue(
new CellKey(address.
Column, address.
Row), out
Cell cell))
1874 return cells.ContainsKey(
new CellKey(address.
Column, address.
Row));
1886 public bool HasCell(
int columnNumber,
int rowNumber)
1898 if (columns.TryGetValue(columnNumber, out var value) && !value.HasAutoFilter)
1900 columns.Remove(columnNumber);
1902 else if (columns.TryGetValue(columnNumber, out var value2))
1904 value2.IsHidden =
false;
1914 public IReadOnlyList<Cell>
GetRow(
int rowNumber)
1916 List<Cell> list =
new List<Cell>();
1917 foreach (
Cell cell
in cells.Values)
1924 list.Sort((c1, c2) => (c1.ColumnNumber.CompareTo(c2.ColumnNumber)));
1947 List<Cell> list =
new List<Cell>();
1948 foreach (
Cell cell
in cells.Values)
1955 list.Sort((c1, c2) => (c1.RowNumber.CompareTo(c2.RowNumber)));
1965 return currentColumnNumber;
1974 return currentRowNumber;
1982 currentColumnNumber++;
1983 currentRowNumber = 0;
1995 currentColumnNumber += numberOfColumns;
1996 if (!keepRowPosition)
1998 currentRowNumber = 0;
2009 currentColumnNumber = 0;
2019 public void GoToNextRow(
int numberOfRows,
bool keepColumnPosition =
false)
2021 currentRowNumber += numberOfRows;
2022 if (!keepColumnPosition)
2024 currentColumnNumber = 0;
2062 string key = startAddress +
":" + endAddress;
2063 Range value =
new Range(startAddress, endAddress);
2065 foreach (KeyValuePair<string, Range> item
in mergedCells)
2067 if (item.Value.ResolveEnclosedAddresses().Intersect(result).Any())
2069 throw new RangeException(
"The passed range: " + value.ToString() +
" contains cells that are already in the defined merge range: " + item.Key);
2072 mergedCells.Add(key, value);
2079 internal void RecalculateAutoFilter()
2081 if (autoFilterRange ==
null)
2094 for (
int i = start; i <= end; i++)
2096 if (!columns.TryGetValue(i, out var value))
2100 HasAutoFilter =
true
2106 value.HasAutoFilter =
true;
2109 autoFilterRange =
new Range(start, 0, end, endRow);
2115 internal void RecalculateColumns()
2117 List<int> columnsToDelete =
new List<int>();
2118 foreach (KeyValuePair<int, Column> col
in columns)
2120 if (!col.Value.HasAutoFilter && !col.Value.IsHidden && Comparators.CompareDimensions(col.Value.Width,
DefaultWorksheetColumnWidth) == 0 && col.Value.DefaultColumnStyle ==
null)
2122 columnsToDelete.Add(col.Key);
2125 foreach (
int index
in columnsToDelete)
2127 columns.Remove(index);
2136 internal void ResolveMergedCells()
2138 Style mergeStyle = BasicStyles.MergeCellStyle;
2140 foreach (KeyValuePair<string, Range> range
in MergedCells)
2143 List<Address> addresses = Cell.GetCellRange(range.Value.StartAddress, range.Value.EndAddress) as List<Address>;
2144 foreach (Address address
in addresses)
2146 if (!cells.TryGetValue(
new CellKey(address.
Column, address.
Row), out cell))
2150 DataType = Cell.CellType.Empty,
2151 RowNumber = address.
Row,
2152 ColumnNumber = address.Column
2154 AddCell(cell, cell.ColumnNumber, cell.RowNumber);
2158 cell.DataType = Cell.CellType.Empty;
2159 if (cell.CellStyle ==
null)
2161 cell.SetStyle(mergeStyle);
2165 Style mixedMergeStyle = cell.CellStyle;
2168 cell.SetStyle(mixedMergeStyle);
2181 autoFilterRange =
null;
2191 SetColumnHiddenState(columnNumber,
false);
2202 SetColumnHiddenState(columnNumber,
false);
2212 SetRowHiddenState(rowNumber,
false);
2223 if (range ==
null || !mergedCells.ContainsKey(range))
2225 throw new RangeException(
"The cell range " + range +
" was not found in the list of merged cell ranges");
2229 foreach (
Address address
in addresses)
2231 if (cells.TryGetValue(
new CellKey(address.
Column, address.
Row), out
Cell cell))
2237 cell.ResolveCellType();
2240 mergedCells.Remove(range);
2249 if (rowHeights.ContainsKey(rowNumber))
2251 rowHeights.Remove(rowNumber);
2261 if (sheetProtectionValues.Contains(value))
2263 sheetProtectionValues.Remove(value);
2275 useActiveStyle =
false;
2279 useActiveStyle =
true;
2281 activeStyle = style;
2294 if (endColumn < startColumn)
2313 RecalculateAutoFilter();
2314 RecalculateColumns();
2323 private void SetColumnHiddenState(
int columnNumber,
bool state)
2326 if (columns.TryGetValue(columnNumber, out var value))
2328 value.IsHidden = state;
2336 columns.Add(columnNumber, c);
2338 if (!columns[columnNumber].IsHidden && Comparators.CompareDimensions(columns[columnNumber].Width,
DefaultWorksheetColumnWidth) == 0 && !columns[columnNumber].HasAutoFilter)
2340 columns.Remove(columnNumber);
2369 if (columns.TryGetValue(columnNumber, out var value))
2371 value.Width = width;
2379 columns.Add(columnNumber, c);
2405 if (this.columns.TryGetValue(columnNumber, out var value))
2407 return value.SetDefaultColumnStyle(style);
2413 this.columns.Add(columnNumber, c);
2452 currentColumnNumber = columnNumber;
2463 currentRowNumber = rowNumber;
2491 Range? resolved = ParseRange(rangeOrAddress);
2492 if (resolved !=
null)
2512 selectedCells.Clear();
2531 Range? resolved = ParseRange(rangeOrAddress);
2532 if (resolved !=
null)
2563 if (
string.IsNullOrEmpty(password))
2565 sheetProtectionPassword.UnsetPassword();
2570 sheetProtectionPassword.SetPassword(password);
2588 if (rowHeights.ContainsKey(rowNumber))
2590 rowHeights[rowNumber] = height;
2594 rowHeights.Add(rowNumber, height);
2604 private void SetRowHiddenState(
int rowNumber,
bool state)
2607 if (hiddenRows.ContainsKey(rowNumber))
2611 hiddenRows[rowNumber] =
true;
2615 hiddenRows.Remove(rowNumber);
2620 hiddenRows.Add(rowNumber,
true);
2662 SetSplit(
null, topPaneHeight, topLeftCell, activePane);
2675 SetSplit(
null, numberOfRowsFromTop, freeze, topLeftCell, activePane);
2686 SetSplit(leftPaneWidth,
null, topLeftCell, activePane);
2700 SetSplit(numberOfColumnsFromLeft,
null, freeze, topLeftCell, activePane);
2718 if (numberOfColumnsFromLeft !=
null && topLeftCell.
Column < numberOfColumnsFromLeft.Value)
2721 " is not valid for a frozen, vertical split with the split pane column number " + numberOfColumnsFromLeft.Value);
2723 if (numberOfRowsFromTop !=
null && topLeftCell.
Row < numberOfRowsFromTop.Value)
2726 " is not valid for a frozen, horizontal split height the split pane row number " + numberOfRowsFromTop.Value);
2729 this.paneSplitLeftWidth =
null;
2730 this.paneSplitTopHeight =
null;
2731 this.freezeSplitPanes = freeze;
2732 int row = numberOfRowsFromTop !=
null ? numberOfRowsFromTop.Value : 0;
2733 int column = numberOfColumnsFromLeft !=
null ? numberOfColumnsFromLeft.Value : 0;
2734 this.paneSplitAddress =
new Address(column, row);
2735 this.paneSplitTopLeftCell = topLeftCell;
2736 this.activePane = activePane;
2750 this.paneSplitLeftWidth = leftPaneWidth;
2751 this.paneSplitTopHeight = topPaneHeight;
2752 this.freezeSplitPanes =
null;
2753 this.paneSplitAddress =
null;
2754 this.paneSplitTopLeftCell = topLeftCell;
2755 this.activePane = activePane;
2763 this.paneSplitLeftWidth =
null;
2764 this.paneSplitTopHeight =
null;
2765 this.freezeSplitPanes =
null;
2766 this.paneSplitAddress =
null;
2767 this.paneSplitTopLeftCell =
null;
2768 this.activePane =
null;
2783 foreach (
Cell cell
in this.cells.Values)
2787 copy.activePane = this.activePane;
2788 copy.activeStyle = this.activeStyle;
2789 if (this.autoFilterRange.HasValue)
2791 copy.autoFilterRange = this.autoFilterRange.Value.Copy();
2793 foreach (KeyValuePair<int, Column> column
in this.columns)
2795 copy.columns.Add(column.Key, column.Value.Copy());
2797 copy.CurrentCellDirection = this.CurrentCellDirection;
2798 copy.currentColumnNumber = this.currentColumnNumber;
2799 copy.currentRowNumber = this.currentRowNumber;
2800 copy.defaultColumnWidth = this.defaultColumnWidth;
2801 copy.defaultRowHeight = this.defaultRowHeight;
2802 copy.freezeSplitPanes = this.freezeSplitPanes;
2803 copy.hidden = this.hidden;
2804 foreach (KeyValuePair<int, bool> row
in this.hiddenRows)
2806 copy.hiddenRows.Add(row.Key, row.Value);
2808 foreach (KeyValuePair<string, Range> cell
in this.mergedCells)
2810 copy.mergedCells.Add(cell.Key, cell.
Value.Copy());
2812 if (this.paneSplitAddress.HasValue)
2814 copy.paneSplitAddress = this.paneSplitAddress.Value.Copy();
2816 copy.paneSplitLeftWidth = this.paneSplitLeftWidth;
2817 copy.paneSplitTopHeight = this.paneSplitTopHeight;
2818 if (this.paneSplitTopLeftCell.HasValue)
2820 copy.paneSplitTopLeftCell = this.paneSplitTopLeftCell.Value.Copy();
2822 foreach (KeyValuePair<int, float> row
in this.rowHeights)
2824 copy.rowHeights.Add(row.Key, row.Value);
2826 foreach (
Range range
in selectedCells)
2828 copy.AddSelectedCells(range);
2830 copy.sheetProtectionPassword.CopyFrom(this.sheetProtectionPassword);
2833 copy.sheetProtectionValues.Add(value);
2835 copy.useActiveStyle = this.useActiveStyle;
2836 copy.UseSheetProtection = this.UseSheetProtection;
2837 copy.ShowGridLines = this.ShowGridLines;
2838 copy.ShowRowColumnHeaders = this.ShowRowColumnHeaders;
2839 copy.ShowRuler = this.ShowRuler;
2840 copy.ViewType = this.ViewType;
2841 copy.zoomFactor.Clear();
2842 foreach (KeyValuePair<SheetViewType, int> zoomFactor
in this.zoomFactor)
2844 copy.SetZoomFactor(zoomFactor.Key, zoomFactor.Value);
2862 if (this.zoomFactor.ContainsKey(sheetViewType))
2864 this.zoomFactor[sheetViewType] = zoomFactor;
2868 this.zoomFactor.Add(sheetViewType, zoomFactor);
2874 #region static_methods
2884 if (
string.IsNullOrEmpty(input))
2899 for (
int i = 0; i < len; i++)
2902 if (c ==
'[' || c ==
']' || c ==
'*' || c ==
'?' || c ==
'\\' || c ==
'/')
2907 return GetUnusedWorksheetName(sb.ToString(), workbook);
2915 private static Range? ParseRange(
string rangeOrAddress)
2917 if (
string.IsNullOrEmpty(rangeOrAddress))
2922 if (rangeOrAddress.Contains(
":"))
2928 Address address = Cell.ResolveCellCoordinate(rangeOrAddress);
2929 range =
new Range(address, address);
2943 private static string GetUnusedWorksheetName(
string name, Workbook workbook)
2945 if (workbook ==
null)
2947 throw new WorksheetException(
"The workbook reference is null");
2949 if (!WorksheetExists(name, workbook))
2951 Regex regex =
new Regex(
@"^(.*?)(\d{1,31})$");
2952 Match match = regex.Match(name);
2953 string prefix = name;
2955 if (match.Groups.Count > 1)
2957 prefix = match.Groups[1].Value;
2958 _ =
int.TryParse(match.Groups[2].Value, out number);
2963 string numberString = ParserUtils.ToString(number);
2967 prefix = prefix.Substring(0, endIndex);
2969 string newName = prefix + numberString;
2970 if (!WorksheetExists(newName, workbook))
2982 private static bool WorksheetExists(
string name, Workbook workbook)
2985 for (
int i = 0; i < len; i++)
2987 if (workbook.
Worksheets[i].SheetName == name)
3027 internal static WorksheetPane? GetWorksheetPaneEnum(
string pane)
3034 case "bottomLeft": output =
WorksheetPane.BottomLeft;
break;
3035 case "bottomRight": output =
WorksheetPane.BottomRight;
break;
3045 internal static SheetViewType GetSheetViewTypeEnum(
string viewType)
3050 case "pageBreakPreview": output =
SheetViewType.PageBreakPreview;
break;
3051 case "pageLayout": output =
SheetViewType.PageLayout;
break;
Class representing a cell of a worksheet.
static Address ResolveCellCoordinate(string address)
Gets the column and row number (zero based) of a cell by the address.
CellType
Enum defines the basic data types of a cell.
static void ValidateRowNumber(int row)
Validates the passed (zero-based) row number. An exception will be thrown if the row is invalid.
Address CellAddress2
Gets or sets the combined cell Address as Address object.
static string ResolveCellAddress(int column, int row, AddressType type=AddressType.Default)
Gets the address of a cell by the column and row number (zero based).
static AddressScope GetAddressScope(string addressExpression)
Gets the scope of the passed address (string expression). Scope means either single cell address or r...
Style CellStyle
Gets the assigned style of the cell.
static Range ResolveCellRange(string range)
Resolves a cell range from the format like A1:B3 or AAD556:AAD1000.
int RowNumber
Gets or sets the number of the row (zero-based).
static void ValidateColumnNumber(int column)
Validates the passed (zero-based) column number. An exception will be thrown if the column is invalid...
static int ResolveColumn(string columnAddress)
Gets the column number from the column address (A - XFD).
CellType DataType
Gets or sets the type of the cell.
string CellAddress
Gets or sets the combined cell Address as string in the format A1 - XFD1048576. The address may conta...
AddressScope
Enum to define the scope of a passed address string (used in static context).
FormulaData Formula
Formula object in case of the cell has the DataType CellType.Formula. Default is null,...
int ColumnNumber
Gets or sets the number of the column (zero-based).
Style SetStyle(Style style, bool unmanaged=false)
Sets the style of the cell.
static IEnumerable< Address > GetCellRange(string range)
Gets a list of cell addresses from a cell range (format A1:B3 or AAD556:AAD1000).
object Value
Gets or sets the value of the cell (generic object type). When setting a value, the DataType is autom...
Class representing a column of a worksheet.
Style SetDefaultColumnStyle(Style defaultColumnStyle, bool unmanaged=false)
Sets the default style of the column.
Class representing a defined name within a workbook. A defined name is a descriptive text that repres...
string Name
Gets the name of the defined name as it appears in the workbook (e.g. MyRange).
Class for exceptions regarding range incidents (e.g. out-of-range).
Class for exceptions regarding worksheet incidents.
Class implementing a legacy password, based on the proprietary hashing algorithm of Excel.
PasswordType
Target type of the password.
Class to register plug-in classes that extends the functionality of NanoXLSX (Core or any other packa...
static bool Initialize()
Initializes the plug-in loader process. If already initialized, the method returns without action.
bool Equals(AbstractStyle other)
Method to compare two objects for sorting purpose.
Factory class with the most important predefined styles.
static Style MergeCellStyle
Gets the style used when merging cells.
bool ForceApplyAlignment
Gets or sets whether the applyAlignment property (used to merge cells) will be defined in the XF entr...
Class representing a Style with sub classes within a style sheet. An instance of this class is only a...
override AbstractStyle Copy()
Method to copy the current object to a new one without casting.
CellXf CurrentCellXf
Gets or sets the current CellXf object of the style.
Style Append(AbstractStyle styleToAppend)
Appends the specified style parts to the current one. The parts can be instances of sub-classes like ...
General data utils class with static methods.
static IReadOnlyList< Range > MergeRange(List< Range > givenRanges, Range newRange, RangeMergeStrategy strategy=RangeMergeStrategy.MergeColumns)
Merges a range with a list of given ranges. If there is no intersection between the list and the new ...
static IReadOnlyList< Range > SubtractRange(List< Range > givenRanges, Range rangeToRemove, RangeMergeStrategy strategy=RangeMergeStrategy.MergeColumns)
Subtracts a range form a list of given ranges. If the range to be removed does not intersect any of t...
Class providing static methods to parse string values to specific types or to print object as languag...
static string ToUpper(string input)
Transforms a string to upper case with null check and invariant culture.
Class providing general validator methods.
static void ValidateWorksheetName(string name)
Validates the passed string, whether it is an expression that can be used as worksheet name.
Class representing a workbook.
List< Worksheet > Worksheets
Gets the list of worksheets in the workbook.
Dictionary< int, bool > HiddenRows
Gets the hidden rows as dictionary with the zero-based row number as key and a boolean as value....
Cell FirstCellByValue(object searchValue)
Searches for the first occurrence of the value.
int GetFirstDataRowNumber()
Gets the first existing row number with data in the current worksheet (zero-based).
static readonly int MaxWorksheetNameLength
Maximum number of characters a worksheet name can have.
void SetStyle(Range cellRange, Style style)
Sets the passed style on the passed cell range. If cells are already existing, the style will be adde...
float DefaultColumnWidth
Gets or sets the default column width.
void AddCellFormula(string formula, string address, Style style)
Adds a formula of the type FormulaData.FormulaType.Normal as string expression to the defined cell ad...
WorksheetPane
Enum to define the pane position or active pane in a slip worksheet.
@ TopRight
The pane is located in the top right of the split worksheet.
@ BottomRight
The pane is located in the bottom right of the split worksheet.
@ BottomLeft
The pane is located in the bottom left of the split worksheet.
@ TopLeft
The pane is located in the top left of the split worksheet.
void SetHorizontalSplit(float topPaneHeight, Address topLeftCell, WorksheetPane? activePane)
Sets the horizontal split of the worksheet into two panes. The measurement in characters cannot be us...
float DefaultRowHeight
Gets or sets the default Row height.
int ZoomFactor
Gets or sets the zoom factor of the ViewType of the current worksheet. If AutoZoomFactor,...
void GoToNextRow()
Moves the current position to the next row (use for a new line).
int SheetID
Gets or sets the internal ID of the worksheet.
void RemoveHiddenRow(int rowNumber)
Sets a previously defined, hidden row as visible again.
CellDirection
Enum to define the direction when using AddNextCell method.
@ RowToRow
The next cell will be on the same column (A1,A2,A3...).
@ ColumnToColumn
The next cell will be on the same row (A1,B1,C1...).
@ Disabled
The address of the next cell will be not changed when adding a cell (for manual definition of cell ad...
int GetLastColumnNumber()
Gets the last existing column number in the current worksheet (zero-based).
WorksheetPane? ActivePane
Gets the active Pane is splitting is applied. The value is nullable. If null, no splitting was defin...
bool ShowRuler
Gets or sets whether a ruler is displayed over the column headers. This value only applies if ViewTyp...
int GetCurrentColumnNumber()
Gets the current column number (zero based).
void ClearSelectedCells()
Removes all cell selections of this worksheet.
bool UseSheetProtection
Gets or sets whether the worksheet is protected. If true, protection is enabled.
void InsertRow(int rowNumber, int numberOfNewRows)
Inserts 'count' rows below the specified 'rowNumber'. Existing cells are moved down by the number of ...
void SetSheetProtectionPassword(string password)
Sets or removes the password for worksheet protection. If set, UseSheetProtection will be also set to...
Dictionary< SheetViewType, int > ZoomFactors
Gets all defined zoom factors per SheetViewType of the current worksheet. Use SetZoomFactor(SheetView...
SheetViewType
Enum to define how a worksheet is displayed in the spreadsheet application (Excel).
@ PageBreakPreview
The worksheet is displayed with indicators where the page would break if it were printed.
@ PageLayout
The worksheet is displayed like it would be printed.
@ Normal
The worksheet is displayed without pagination (default).
void GoToNextColumn()
Moves the current position to the next column.
void AddNextCellFormula(string formula, Style style)
Adds a formula of the type FormulaData.FormulaType.Normal as string expression to the next cell posit...
void SetRowHeight(int rowNumber, float height)
Sets the height of the passed row number (zero-based).
Worksheet(string name)
Constructor with worksheet name.
int GetFirstColumnNumber()
Gets the first existing column number in the current worksheet (zero-based).
void AddHiddenColumn(int columnNumber)
Sets the defined column as hidden.
CellDirection CurrentCellDirection
Gets or sets the direction when using AddNextCell method.
Cell GetCell(Address address)
Gets the cell of the specified address.
IReadOnlyList< Cell > GetRow(int rowNumber)
Gets a row as list of cell objects.
int ReplaceCellValue(object oldValue, object newValue)
Replaces all occurrences of 'oldValue' with 'newValue' and returns the number of replacements.
static readonly int MinColumnNumber
Minimum column number (zero-based) as constant.
IReadOnlyList< Address > AddCellReference(DefinedName definedName, int columnNumber, int rowNumber, Style style, object cachedValue=null)
Adds a cell whose content is a reference to a DefinedName in the workbook (either workbook-scoped or ...
void AddSelectedCells(string rangeOrAddress)
Adds a range or cell address to the selected cells on this worksheet.
Worksheet Copy()
Creates a (dereferenced) deep copy of this worksheet.
void SetCurrentCellAddress(int columnNumber, int rowNumber)
Set the current cell address.
string MergeCells(string cellRange)
Merges the defined cell range.
IReadOnlyList< Address > AddCellReference(DefinedName definedName, string address, Style style, object cachedValue=null)
Adds a cell whose content is a reference to a DefinedName in the workbook (either workbook-scoped or ...
bool ShowGridLines
Gets or sets whether grid lines are visible on the current worksheet. Default is true.
IReadOnlyList< Cell > GetColumn(int columnNumber)
Gets a column as list of cell objects.
Address? GetLastDataCellAddress()
Gets the last existing cell with data in the current worksheet (bottom right).
void AddSelectedCells(Address startAddress, Address endAddress)
Adds a range to the selected cells on this worksheet.
void InsertColumn(int columnNumber, int numberOfNewColumns)
Inserts 'count' columns right of the specified 'columnNumber'. Existing cells are moved to the right ...
SheetProtectionValue
Enum to define the possible protection types when protecting a worksheet.
@ PivotTables
If selected, the user can use pivot tables if the worksheets is protected.
@ FormatCells
If selected, the user can format cells if the worksheets is protected.
@ InsertHyperlinks
If selected, the user can insert hyper links if the worksheets is protected.
@ InsertColumns
If selected, the user can insert columns if the worksheets is protected.
@ Sort
If selected, the user can sort cells if the worksheets is protected.
@ DeleteColumns
If selected, the user can delete columns if the worksheets is protected.
@ Scenarios
If selected, the user can edit scenarios if the worksheets is protected.
@ DeleteRows
If selected, the user can delete rows if the worksheets is protected.
@ FormatColumns
If selected, the user can format columns if the worksheets is protected.
@ InsertRows
If selected, the user can insert rows if the worksheets is protected.
@ FormatRows
If selected, the user can format rows if the worksheets is protected.
@ AutoFilter
If selected, the user can use auto filters if the worksheets is protected.
@ Objects
If selected, the user can edit objects if the worksheets is protected.
@ SelectUnlockedCells
If selected, the user can select unlocked cells if the worksheets is protected.
@ SelectLockedCells
If selected, the user can select locked cells if the worksheets is protected.
Style SetColumnDefaultStyle(int columnNumber, Style style)
Sets the default column style of the passed column number (zero-based).
Worksheet(string name, int id, Workbook reference)
Constructor with name and sheet ID.
void SetColumnWidth(string columnAddress, float width)
Sets the width of the passed column address.
void SetSplit(float? leftPaneWidth, float? topPaneHeight, Address topLeftCell, WorksheetPane? activePane)
Sets the horizontal and vertical split of the worksheet into four panes. The measurement in character...
Address? GetFirstCellAddress()
Gets the first existing cell in the current worksheet (bottom right).
void AddCellRange(IReadOnlyList< object > values, Range cellRange, Style style)
Adds a list of object values to a defined cell range. If the type of the particular value does not ma...
void AddHiddenColumn(string columnAddress)
Sets the defined column as hidden.
IReadOnlyList< Cell > GetColumn(string columnAddress)
Gets a column as list of cell objects.
void SetStyle(string addressExpression, Style style)
Sets the passed style on the passed address expression. Such an expression may be a single cell or a ...
static readonly float DefaultWorksheetColumnWidth
Default column width as constant.
static readonly float DefaultWorksheetRowHeight
Default row height as constant.
Address? GetLastCellAddress()
Gets the last existing cell in the current worksheet (bottom right).
bool HasCell(int columnNumber, int rowNumber)
Gets whether the specified address exists in the worksheet. Existing means that a value was stored at...
static readonly int MaxRowNumber
Maximum row number (zero-based) as constant.
int GetLastDataRowNumber()
Gets the last existing row number with data in the current worksheet (zero-based).
void ResetSplit()
Resets splitting of the worksheet into panes, as well as their freezing.
void SetCurrentCellAddress(string address)
Set the current cell address.
void RemoveSelectedCells(Address address)
Removes the given address from the selected cell ranges of this worksheet, if existing.
Address? PaneSplitTopLeftCell
Gets the Top Left cell address of the bottom right pane if applicable and splitting is applied....
void ClearActiveStyle()
Clears the active style of the worksheet. All later added calls will contain no style unless another ...
void SetHorizontalSplit(int numberOfRowsFromTop, bool freeze, Address topLeftCell, WorksheetPane? activePane)
Sets the horizontal split of the worksheet into two panes. The measurement in rows can be used to spl...
void RemoveAutoFilter()
Removes auto filters from the worksheet.
void GoToNextRow(int numberOfRows, bool keepColumnPosition=false)
Moves the current position to the next row with the number of cells to move (use for a new line).
string MergeCells(Range cellRange)
Merges the defined cell range.
bool RemoveCell(int columnNumber, int rowNumber)
Removes a previous inserted cell at the defined address.
void AddSelectedCells(Address address)
Adds a single cell address to the selected cells on this worksheet.
void SetSplit(int? numberOfColumnsFromLeft, int? numberOfRowsFromTop, bool freeze, Address topLeftCell, WorksheetPane? activePane)
Sets the horizontal and vertical split of the worksheet into four panes. The measurement in rows and ...
Style SetColumnDefaultStyle(string columnAddress, Style style)
Sets the default column style of the passed column address.
void RemoveSelectedCells(String rangeOrAddress)
Removes the given range or cell address from the selected cell ranges of this worksheet,...
IEnumerable< Cell > CellValues
Gets all cells of the worksheet as an enumerable sequence. Preferred over Cells in performance-critic...
void AddCellRange(IReadOnlyList< object > values, Range cellRange)
Adds a list of object values to a defined cell range. If the type of the particular value does not ma...
void AddAllowedActionOnSheetProtection(SheetProtectionValue typeOfProtection)
Method to add allowed actions if the worksheet is protected. If one or more values are added,...
void SetAutoFilter(string range)
Sets the column auto filter within the defined column range.
static readonly int MaxColumnNumber
Maximum column number (zero-based) as constant.
void AddCellFormula(string formula, string address)
Adds a formula of the type FormulaData.FormulaType.Normal as string expression to the defined cell ad...
IReadOnlyList< Address > AddCellReference(DefinedName definedName, string address, object cachedValue=null)
Adds a cell whose content is a reference to a DefinedName in the workbook (either workbook-scoped or ...
void SetVerticalSplit(float leftPaneWidth, Address topLeftCell, WorksheetPane? activePane)
Sets the vertical split of the worksheet into two panes. The measurement in characters cannot be used...
void AddCell(object value, int columnNumber, int rowNumber)
Adds an object to the defined cell address. If the type of the value does not match with one of the s...
void SetCurrentColumnNumber(int columnNumber)
Sets the current column number (zero based).
Address? GetFirstDataCellAddress()
Gets the first existing cell with data in the current worksheet (bottom right).
void SetVerticalSplit(int numberOfColumnsFromLeft, bool freeze, Address topLeftCell, WorksheetPane? activePane)
Sets the vertical split of the worksheet into two panes. The measurement in columns can be used to sp...
SheetViewType ViewType
Gets or sets how the current worksheet is displayed in the spreadsheet application (Excel).
string SheetName
Gets or sets the name of the worksheet.
void AddCellFormula(string formula, int columnNumber, int rowNumber)
Adds a formula of the type FormulaData.FormulaType.Normal as string expression to the defined cell ad...
bool HasCell(Address address)
Gets whether the specified address exists in the worksheet. Existing means that a value was stored at...
Workbook WorkbookReference
Gets or sets the Reference to the parent Workbook.
const int AutoZoomFactor
Automatic zoom factor of a worksheet.
float? PaneSplitTopHeight
Gets the height of the upper, horizontal split pane, measured from the top of the window....
Address? PaneSplitAddress
Gets the split address for frozen panes or if pane split was defined in number of columns and / or ro...
Cell FirstOrDefaultCell(Func< Cell, bool > predicate)
Searches for the first occurrence of the expression. Example: var cell = worksheet....
Worksheet()
Default Constructor.
void RemoveSelectedCells(Range range)
Removes the given range from the selected cell ranges of this worksheet, if existing....
List< Range > SelectedCells
Gets the cell ranges of selected cells of this worksheet. Returns ans empty list if no cells are sele...
void SetSheetName(string name)
Validates and sets the worksheet name.
int GetLastDataColumnNumber()
Gets the last existing column number with data in the current worksheet (zero-based).
string MergeCells(Address startAddress, Address endAddress)
Merges the defined cell range.
void AddCellRange(IReadOnlyList< object > values, Address startAddress, Address endAddress, Style style)
Adds a list of object values to a defined cell range. If the type of the particular value does not ma...
int GetFirstRowNumber()
Gets the first existing row number in the current worksheet (zero-based).
void SetActiveStyle(Style style)
Sets the active style of the worksheet. This style will be assigned to all later added cells.
int GetFirstDataColumnNumber()
Gets the first existing column number with data in the current worksheet (zero-based).
List< SheetProtectionValue > SheetProtectionValues
Gets the list of SheetProtectionValues. These values define the allowed actions if the worksheet is p...
void SetZoomFactor(SheetViewType sheetViewType, int zoomFactor)
Sets a zoom factor for a given SheetViewType. If AutoZoomFactor, the zoom factor is set to automatic.
static string SanitizeWorksheetName(string input, Workbook workbook)
Sanitizes a worksheet name.
void SetStyle(Address address, Style style)
Sets the passed style on the passed (singular) cell address. If the cell is already existing,...
void AddHiddenRow(int rowNumber)
Sets the defined row as hidden.
void AddCell(object value, string address)
Adds an object to the defined cell address. If the type of the value does not match with one of the s...
static readonly float MinColumnWidth
Minimum column width as constant.
void RemoveMergedCells(string range)
Removes the defined merged cell range.
static readonly int MinRowNumber
Minimum row number (zero-based) as constant.
void AddNextCell(object value, Style style)
Adds an object to the next cell position. If the type of the value does not match with one of the sup...
Dictionary< int, float > RowHeights
Gets defined row heights as dictionary with the zero-based row number as key and the height (float fr...
void AddCell(object value, string address, Style style)
Adds an object to the defined cell address. If the type of the value does not match with one of the s...
void AddCellRange(IReadOnlyList< object > values, Address startAddress, Address endAddress)
Adds a list of object values to a defined cell range. If the type of the particular value does not ma...
bool ShowRowColumnHeaders
Gets or sets whether the column and row headers are visible on the current worksheet....
virtual IPassword SheetProtectionPassword
Password instance of the worksheet protection. If a password was set, the pain text representation an...
const int maxZoomFactor
Maximum zoom factor of a worksheet.
void SetColumnWidth(int columnNumber, float width)
Sets the width of the passed column number (zero-based).
static readonly float MaxColumnWidth
Maximum column width as constant.
Dictionary< string, Range > MergedCells
Gets the merged cells (only references) as dictionary with the cell address as key and the range obje...
void SetSheetName(string name, bool sanitize)
Sets the name of the worksheet.
bool? FreezeSplitPanes
Gets whether split panes are frozen. The value is nullable. If null, no freezing is applied....
void AddSelectedCells(Range range)
Adds a range to the selected cells on this worksheet.
const int MaxZoomFactor
Maximum zoom factor of a worksheet.
IReadOnlyDictionary< string, Cell > Cells
Gets the cells of the worksheet as read-only dictionary with the cell address string as key and the c...
void AddCellRange(IReadOnlyList< object > values, string cellRange, Style style)
Adds a list of object values to a defined cell range. If the type of the particular value does not ma...
void AddCellRange(IReadOnlyList< object > values, string cellRange)
Adds a list of object values to a defined cell range. If the type of the particular value does not ma...
void AddNextCell(object value)
Adds an object to the next cell position. If the type of the value does not match with one of the sup...
IReadOnlyList< Address > AddCellReference(DefinedName definedName, int columnNumber, int rowNumber, object cachedValue=null)
Adds a cell whose content is a reference to a DefinedName in the workbook (either workbook-scoped or ...
void RemoveHiddenColumn(int columnNumber)
Sets a previously defined, hidden column as visible again.
void RemoveHiddenColumn(string columnAddress)
Sets a previously defined, hidden column as visible again.
Range? AutoFilterRange
Gets the range of the auto-filter. Wrapped to Nullable to provide null as value. If null,...
const int MinZoomFactor
Minimum zoom factor of a worksheet. If set to this value, the zoom is set to automatic.
bool RemoveCell(string address)
Removes a previous inserted cell at the defined address.
int GetLastRowNumber()
Gets the last existing row number in the current worksheet (zero-based).
void ResetColumn(int columnNumber)
Resets the defined column, if existing. The corresponding instance will be removed from Columns.
void SetCurrentRowNumber(int rowNumber)
Sets the current row number (zero based).
void AddCell(object value, int columnNumber, int rowNumber, Style style)
Adds an object to the defined cell address. If the type of the value does not match with one of the s...
void AddNextCellFormula(string formula)
Adds a formula of the type FormulaData.FormulaType.Normal as string expression to the next cell posit...
void RemoveAllowedActionOnSheetProtection(SheetProtectionValue value)
Removes an allowed action on the current worksheet or its cells.
int GetCurrentRowNumber()
Gets the current row number (zero based).
static readonly float MinRowHeight
Minimum row height as constant.
List< Cell > CellsByValue(object searchValue)
Searches for cells that contain the specified value and returns a list of these cells.
Style ActiveStyle
Gets the active Style of the worksheet. If null, no style is defined as active.
static readonly float MaxRowHeight
Maximum row height as constant.
void AddCellFormula(string formula, int columnNumber, int rowNumber, Style style)
Adds a formula of the type FormulaData.FormulaType.Normal as string expression to the defined cell ad...
void RemoveRowHeight(int rowNumber)
Removes the defined, non-standard row height.
void SetStyle(Address startAddress, Address endAddress, Style style)
Sets the passed style on the passed cell range, derived from a start and end address....
void SetAutoFilter(int startColumn, int endColumn)
Sets the column auto filter within the defined column range.
void GoToNextColumn(int numberOfColumns, bool keepRowPosition=false)
Moves the current position to the next column with the number of cells to move.
bool Hidden
gets or sets whether the worksheet is hidden. If true, the worksheet is not listed in the worksheet t...
void RemoveSelectedCells(Address startAddress, Address endAddress)
Removes the given range from the selected cell ranges of this worksheet, if existing.
Dictionary< int, Column > Columns
Gets all columns with non-standard properties, like auto filter applied or a special width as diction...
float? PaneSplitLeftWidth
Gets the width of the left, vertical split pane, measured from the left of the window....
Cell GetCell(int columnNumber, int rowNumber)
Gets the cell of the specified column and row number (zero-based).
Interface to represent a protection password, either for workbooks or worksheets. The implementations...
Struct representing the cell address as column and row (zero based).
int Row
Row number (zero based).
string GetAddress()
Returns the combined Address.
int Column
Column number (zero based).
Struct representing a cell range with a start and end address.
override string ToString()
Overwritten ToString method.
IReadOnlyList< Address > ResolveEnclosedAddresses()
Gets a list of all addresses between the start and end address.
Address StartAddress
Start address of the range.
Address EndAddress
End address of the range.