/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheet.cs

# · C# · 364 lines · 116 code · 42 blank · 206 comment · 0 complexity · b2ffb0a6982496e2bdefce232319a454 MD5 · raw file

  1. using System;
  2. namespace ClosedXML.Excel
  3. {
  4. public enum XLWorksheetVisibility { Visible, Hidden, VeryHidden }
  5. public interface IXLWorksheet : IXLRangeBase
  6. {
  7. /// <summary>
  8. /// Gets the workbook that contains this worksheet
  9. /// </summary>
  10. XLWorkbook Workbook { get; }
  11. /// <summary>
  12. /// Gets or sets the default column width for this worksheet.
  13. /// </summary>
  14. Double ColumnWidth { get; set; }
  15. /// <summary>
  16. /// Gets or sets the default row height for this worksheet.
  17. /// </summary>
  18. Double RowHeight { get; set; }
  19. /// <summary>
  20. /// Gets or sets the name (caption) of this worksheet.
  21. /// </summary>
  22. String Name { get; set; }
  23. /// <summary>
  24. /// Gets or sets the position of the sheet.
  25. /// <para>When setting the Position all other sheets' positions are shifted accordingly.</para>
  26. /// </summary>
  27. Int32 Position { get; set; }
  28. /// <summary>
  29. /// Gets an object to manipulate the sheet's print options.
  30. /// </summary>
  31. IXLPageSetup PageSetup { get; }
  32. /// <summary>
  33. /// Gets an object to manipulate the Outline levels.
  34. /// </summary>
  35. IXLOutline Outline { get; }
  36. /// <summary>
  37. /// Gets the first row of the worksheet.
  38. /// </summary>
  39. IXLRow FirstRow();
  40. /// <summary>
  41. /// Gets the first row of the worksheet that contains a cell with a value.
  42. /// <para>Formatted empty cells do not count.</para>
  43. /// </summary>
  44. IXLRow FirstRowUsed();
  45. /// <summary>
  46. /// Gets the first row of the worksheet that contains a cell with a value.
  47. /// </summary>
  48. /// <param name="includeFormats">If set to <c>true</c> formatted empty cells will count as used.</param>
  49. IXLRow FirstRowUsed(Boolean includeFormats);
  50. /// <summary>
  51. /// Gets the last row of the worksheet.
  52. /// </summary>
  53. IXLRow LastRow();
  54. /// <summary>
  55. /// Gets the last row of the worksheet that contains a cell with a value.
  56. /// </summary>
  57. IXLRow LastRowUsed();
  58. /// <summary>
  59. /// Gets the last row of the worksheet that contains a cell with a value.
  60. /// </summary>
  61. /// <param name="includeFormats">If set to <c>true</c> formatted empty cells will count as used.</param>
  62. IXLRow LastRowUsed(Boolean includeFormats);
  63. /// <summary>
  64. /// Gets the first column of the worksheet.
  65. /// </summary>
  66. IXLColumn FirstColumn();
  67. /// <summary>
  68. /// Gets the first column of the worksheet that contains a cell with a value.
  69. /// </summary>
  70. IXLColumn FirstColumnUsed();
  71. /// <summary>
  72. /// Gets the first column of the worksheet that contains a cell with a value.
  73. /// </summary>
  74. /// <param name="includeFormats">If set to <c>true</c> formatted empty cells will count as used.</param>
  75. IXLColumn FirstColumnUsed(Boolean includeFormats);
  76. /// <summary>
  77. /// Gets the last column of the worksheet.
  78. /// </summary>
  79. IXLColumn LastColumn();
  80. /// <summary>
  81. /// Gets the last column of the worksheet that contains a cell with a value.
  82. /// </summary>
  83. IXLColumn LastColumnUsed();
  84. /// <summary>
  85. /// Gets the last column of the worksheet that contains a cell with a value.
  86. /// </summary>
  87. /// <param name="includeFormats">If set to <c>true</c> formatted empty cells will count as used.</param>
  88. IXLColumn LastColumnUsed(Boolean includeFormats);
  89. /// <summary>
  90. /// Gets a collection of all columns in this worksheet.
  91. /// </summary>
  92. IXLColumns Columns();
  93. /// <summary>
  94. /// Gets a collection of the specified columns in this worksheet, separated by commas.
  95. /// <para>e.g. Columns("G:H"), Columns("10:11,13:14"), Columns("P:Q,S:T"), Columns("V")</para>
  96. /// </summary>
  97. /// <param name="columns">The columns to return.</param>
  98. IXLColumns Columns(String columns);
  99. /// <summary>
  100. /// Gets a collection of the specified columns in this worksheet.
  101. /// </summary>
  102. /// <param name="firstColumn">The first column to return.</param>
  103. /// <param name="lastColumn">The last column to return.</param>
  104. IXLColumns Columns(String firstColumn, String lastColumn);
  105. /// <summary>
  106. /// Gets a collection of the specified columns in this worksheet.
  107. /// </summary>
  108. /// <param name="firstColumn">The first column to return.</param>
  109. /// <param name="lastColumn">The last column to return.</param>
  110. IXLColumns Columns(Int32 firstColumn, Int32 lastColumn);
  111. /// <summary>
  112. /// Gets a collection of all rows in this worksheet.
  113. /// </summary>
  114. IXLRows Rows();
  115. /// <summary>
  116. /// Gets a collection of the specified rows in this worksheet, separated by commas.
  117. /// <para>e.g. Rows("4:5"), Rows("7:8,10:11"), Rows("13")</para>
  118. /// </summary>
  119. /// <param name="rows">The rows to return.</param>
  120. IXLRows Rows(String rows);
  121. /// <summary>
  122. /// Gets a collection of the specified rows in this worksheet.
  123. /// </summary>
  124. /// <param name="firstRow">The first row to return.</param>
  125. /// <param name="lastRow">The last row to return.</param>
  126. /// <returns></returns>
  127. IXLRows Rows(Int32 firstRow, Int32 lastRow);
  128. /// <summary>
  129. /// Gets the specified row of the worksheet.
  130. /// </summary>
  131. /// <param name="row">The worksheet's row.</param>
  132. IXLRow Row(Int32 row);
  133. /// <summary>
  134. /// Gets the specified column of the worksheet.
  135. /// </summary>
  136. /// <param name="column">The worksheet's column.</param>
  137. IXLColumn Column(Int32 column);
  138. /// <summary>
  139. /// Gets the specified column of the worksheet.
  140. /// </summary>
  141. /// <param name="column">The worksheet's column.</param>
  142. IXLColumn Column(String column);
  143. /// <summary>
  144. /// Gets the cell at the specified row and column.
  145. /// </summary>
  146. /// <param name="row">The cell's row.</param>
  147. /// <param name="column">The cell's column.</param>
  148. IXLCell Cell(int row, int column);
  149. /// <summary>Gets the cell at the specified address.</summary>
  150. /// <param name="cellAddressInRange">The cell address in the worksheet.</param>
  151. IXLCell Cell(string cellAddressInRange);
  152. /// <summary>
  153. /// Gets the cell at the specified row and column.
  154. /// </summary>
  155. /// <param name="row">The cell's row.</param>
  156. /// <param name="column">The cell's column.</param>
  157. IXLCell Cell(int row, string column);
  158. /// <summary>Gets the cell at the specified address.</summary>
  159. /// <param name="cellAddressInRange">The cell address in the worksheet.</param>
  160. IXLCell Cell(IXLAddress cellAddressInRange);
  161. /// <summary>
  162. /// Returns the specified range.
  163. /// </summary>
  164. /// <param name="rangeAddress">The range boundaries.</param>
  165. IXLRange Range(IXLRangeAddress rangeAddress);
  166. /// <summary>Returns the specified range.</summary>
  167. /// <para>e.g. Range("A1"), Range("A1:C2")</para>
  168. /// <param name="rangeAddress">The range boundaries.</param>
  169. IXLRange Range(string rangeAddress);
  170. /// <summary>Returns the specified range.</summary>
  171. /// <param name="firstCell">The first cell in the range.</param>
  172. /// <param name="lastCell"> The last cell in the range.</param>
  173. IXLRange Range(IXLCell firstCell, IXLCell lastCell);
  174. /// <summary>Returns the specified range.</summary>
  175. /// <param name="firstCellAddress">The first cell address in the worksheet.</param>
  176. /// <param name="lastCellAddress"> The last cell address in the worksheet.</param>
  177. IXLRange Range(string firstCellAddress, string lastCellAddress);
  178. /// <summary>Returns the specified range.</summary>
  179. /// <param name="firstCellAddress">The first cell address in the worksheet.</param>
  180. /// <param name="lastCellAddress"> The last cell address in the worksheet.</param>
  181. IXLRange Range(IXLAddress firstCellAddress, IXLAddress lastCellAddress);
  182. /// <summary>Returns a collection of ranges, separated by commas.</summary>
  183. /// <para>e.g. Ranges("A1"), Ranges("A1:C2"), Ranges("A1:B2,D1:D4")</para>
  184. /// <param name="ranges">The ranges to return.</param>
  185. IXLRanges Ranges(string ranges);
  186. /// <summary>Returns the specified range.</summary>
  187. /// <param name="firstCellRow"> The first cell's row of the range to return.</param>
  188. /// <param name="firstCellColumn">The first cell's column of the range to return.</param>
  189. /// <param name="lastCellRow"> The last cell's row of the range to return.</param>
  190. /// <param name="lastCellColumn"> The last cell's column of the range to return.</param>
  191. /// <returns>.</returns>
  192. IXLRange Range(int firstCellRow, int firstCellColumn, int lastCellRow, int lastCellColumn);
  193. /// <summary>Gets the number of rows in this worksheet.</summary>
  194. int RowCount();
  195. /// <summary>Gets the number of columns in this worksheet.</summary>
  196. int ColumnCount();
  197. /// <summary>
  198. /// Collapses all outlined rows.
  199. /// </summary>
  200. IXLWorksheet CollapseRows();
  201. /// <summary>
  202. /// Collapses all outlined columns.
  203. /// </summary>
  204. IXLWorksheet CollapseColumns();
  205. /// <summary>
  206. /// Expands all outlined rows.
  207. /// </summary>
  208. IXLWorksheet ExpandRows();
  209. /// <summary>
  210. /// Expands all outlined columns.
  211. /// </summary>
  212. IXLWorksheet ExpandColumns();
  213. /// <summary>
  214. /// Collapses the outlined rows of the specified level.
  215. /// </summary>
  216. /// <param name="outlineLevel">The outline level.</param>
  217. IXLWorksheet CollapseRows(Int32 outlineLevel);
  218. /// <summary>
  219. /// Collapses the outlined columns of the specified level.
  220. /// </summary>
  221. /// <param name="outlineLevel">The outline level.</param>
  222. IXLWorksheet CollapseColumns(Int32 outlineLevel);
  223. /// <summary>
  224. /// Expands the outlined rows of the specified level.
  225. /// </summary>
  226. /// <param name="outlineLevel">The outline level.</param>
  227. IXLWorksheet ExpandRows(Int32 outlineLevel);
  228. /// <summary>
  229. /// Expands the outlined columns of the specified level.
  230. /// </summary>
  231. /// <param name="outlineLevel">The outline level.</param>
  232. IXLWorksheet ExpandColumns(Int32 outlineLevel);
  233. /// <summary>
  234. /// Deletes this worksheet.
  235. /// </summary>
  236. void Delete();
  237. /// <summary>
  238. /// Gets an object to manage this worksheet's named ranges.
  239. /// </summary>
  240. IXLNamedRanges NamedRanges { get; }
  241. /// <summary>
  242. /// Gets the specified named range.
  243. /// </summary>
  244. /// <param name="rangeName">Name of the range.</param>
  245. IXLNamedRange NamedRange(String rangeName);
  246. /// <summary>
  247. /// Gets an object to manage how the worksheet is going to displayed by Excel.
  248. /// </summary>
  249. IXLSheetView SheetView { get; }
  250. /// <summary>
  251. /// Gets the Excel table of the given index
  252. /// </summary>
  253. /// <param name="index">Index of the table to return</param>
  254. IXLTable Table(Int32 index);
  255. /// <summary>
  256. /// Gets the Excel table of the given name
  257. /// </summary>
  258. /// <param name="name">Name of the table to return</param>
  259. IXLTable Table(String name);
  260. /// <summary>
  261. /// Gets an object to manage this worksheet's Excel tables
  262. /// </summary>
  263. IXLTables Tables { get; }
  264. /// <summary>
  265. /// Copies the
  266. /// </summary>
  267. /// <param name="newSheetName"></param>
  268. /// <returns></returns>
  269. IXLWorksheet CopyTo(String newSheetName);
  270. IXLWorksheet CopyTo(String newSheetName, Int32 position);
  271. IXLWorksheet CopyTo(XLWorkbook workbook, String newSheetName);
  272. IXLWorksheet CopyTo(XLWorkbook workbook, String newSheetName, Int32 position);
  273. IXLRange RangeUsed();
  274. IXLRange RangeUsed(bool includeFormats);
  275. IXLDataValidations DataValidations { get; }
  276. XLWorksheetVisibility Visibility { get; set; }
  277. IXLWorksheet Hide();
  278. IXLWorksheet Unhide();
  279. IXLSheetProtection Protection { get; }
  280. IXLSheetProtection Protect();
  281. IXLSheetProtection Protect(String password);
  282. IXLSheetProtection Unprotect();
  283. IXLSheetProtection Unprotect(String password);
  284. IXLSortElements SortRows { get; }
  285. IXLSortElements SortColumns { get; }
  286. IXLRange Sort();
  287. IXLRange Sort(String columnsToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true);
  288. IXLRange Sort(Int32 columnToSortBy, XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true);
  289. IXLRange SortLeftToRight(XLSortOrder sortOrder = XLSortOrder.Ascending, Boolean matchCase = false, Boolean ignoreBlanks = true);
  290. //IXLCharts Charts { get; }
  291. Boolean ShowFormulas { get; set; }
  292. Boolean ShowGridLines { get; set; }
  293. Boolean ShowOutlineSymbols { get; set; }
  294. Boolean ShowRowColHeaders { get; set; }
  295. Boolean ShowRuler { get; set; }
  296. Boolean ShowWhiteSpace { get; set; }
  297. Boolean ShowZeros { get; set; }
  298. IXLWorksheet SetShowFormulas(); IXLWorksheet SetShowFormulas(Boolean value);
  299. IXLWorksheet SetShowGridLines(); IXLWorksheet SetShowGridLines(Boolean value);
  300. IXLWorksheet SetShowOutlineSymbols(); IXLWorksheet SetShowOutlineSymbols(Boolean value);
  301. IXLWorksheet SetShowRowColHeaders(); IXLWorksheet SetShowRowColHeaders(Boolean value);
  302. IXLWorksheet SetShowRuler(); IXLWorksheet SetShowRuler(Boolean value);
  303. IXLWorksheet SetShowWhiteSpace(); IXLWorksheet SetShowWhiteSpace(Boolean value);
  304. IXLWorksheet SetShowZeros(); IXLWorksheet SetShowZeros(Boolean value);
  305. IXLColor TabColor { get; set; }
  306. IXLWorksheet SetTabColor(IXLColor color);
  307. Boolean TabSelected { get; set; }
  308. Boolean TabActive { get; set; }
  309. IXLWorksheet SetTabSelected(); IXLWorksheet SetTabSelected(Boolean value);
  310. IXLWorksheet SetTabActive(); IXLWorksheet SetTabActive(Boolean value);
  311. IXLPivotTable PivotTable(String name);
  312. IXLPivotTables PivotTables { get; }
  313. Boolean RightToLeft { get; set; }
  314. IXLWorksheet SetRightToLeft(); IXLWorksheet SetRightToLeft(Boolean value);
  315. IXLBaseAutoFilter AutoFilter { get; }
  316. IXLRows RowsUsed(Boolean includeFormats = false, Func<IXLRow, Boolean> predicate = null);
  317. IXLRows RowsUsed(Func<IXLRow, Boolean> predicate);
  318. IXLColumns ColumnsUsed(Boolean includeFormats = false, Func<IXLColumn, Boolean> predicate = null);
  319. IXLColumns ColumnsUsed(Func<IXLColumn, Boolean> predicate);
  320. IXLRanges MergedRanges { get; }
  321. }
  322. }