diff --git a/ClosedXML/ClosedXML.csproj b/ClosedXML/ClosedXML.csproj index 2d8b034..238169d 100644 --- a/ClosedXML/ClosedXML.csproj +++ b/ClosedXML/ClosedXML.csproj @@ -99,6 +99,7 @@ + diff --git a/ClosedXML/Excel/IXLWorkbook.cs b/ClosedXML/Excel/IXLWorkbook.cs new file mode 100644 index 0000000..702c490 --- /dev/null +++ b/ClosedXML/Excel/IXLWorkbook.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Globalization; +using System.IO; + +namespace ClosedXML.Excel +{ + public interface IXLWorkbook : IDisposable + { + String Author { get; set; } + + /// + /// Gets or sets the workbook's calculation mode. + /// + XLCalculateMode CalculateMode { get; set; } + + Boolean CalculationOnSave { get; set; } + + /// + /// Gets or sets the default column width for the workbook. + /// All new worksheets will use this column width. + /// + Double ColumnWidth { get; set; } + + IXLCustomProperties CustomProperties { get; } + + Boolean DefaultRightToLeft { get; } + + Boolean DefaultShowFormulas { get; } + + Boolean DefaultShowGridLines { get; } + + Boolean DefaultShowOutlineSymbols { get; } + + Boolean DefaultShowRowColHeaders { get; } + + Boolean DefaultShowRuler { get; } + + Boolean DefaultShowWhiteSpace { get; } + + Boolean DefaultShowZeros { get; } + + Boolean ForceFullCalculation { get; set; } + + Boolean FullCalculationOnLoad { get; set; } + + Boolean FullPrecision { get; set; } + + Boolean IsPasswordProtected { get; } + + Boolean LockStructure { get; set; } + + Boolean LockWindows { get; set; } + + /// + /// Gets an object to manipulate this workbook's named ranges. + /// + IXLNamedRanges NamedRanges { get; } + + /// + /// Gets or sets the default outline options for the workbook. + /// All new worksheets will use these outline options. + /// + IXLOutline Outline { get; set; } + + /// + /// Gets or sets the default page options for the workbook. + /// All new worksheets will use these page options. + /// + IXLPageSetup PageOptions { get; set; } + + /// + /// Gets or sets the workbook's properties. + /// + XLWorkbookProperties Properties { get; set; } + + /// + /// Gets or sets the workbook's reference style. + /// + XLReferenceStyle ReferenceStyle { get; set; } + + Boolean RightToLeft { get; set; } + + /// + /// Gets or sets the default row height for the workbook. + /// All new worksheets will use this row height. + /// + Double RowHeight { get; set; } + + Boolean ShowFormulas { get; set; } + + Boolean ShowGridLines { get; set; } + + Boolean ShowOutlineSymbols { get; set; } + + Boolean ShowRowColHeaders { get; set; } + + Boolean ShowRuler { get; set; } + + Boolean ShowWhiteSpace { get; set; } + + Boolean ShowZeros { get; set; } + + /// + /// Gets or sets the default style for the workbook. + /// All new worksheets will use this style. + /// + IXLStyle Style { get; set; } + + /// + /// Gets an object to manipulate this workbook's theme. + /// + IXLTheme Theme { get; } + + Boolean Use1904DateSystem { get; set; } + + /// + /// Gets an object to manipulate the worksheets. + /// + IXLWorksheets Worksheets { get; } + + IXLWorksheet AddWorksheet(String sheetName); + + IXLWorksheet AddWorksheet(String sheetName, Int32 position); + + IXLWorksheet AddWorksheet(DataTable dataTable); + + void AddWorksheet(DataSet dataSet); + + void AddWorksheet(IXLWorksheet worksheet); + + IXLWorksheet AddWorksheet(DataTable dataTable, String sheetName); + + IXLCell Cell(String namedCell); + + IXLCells Cells(String namedCells); + + IXLCustomProperty CustomProperty(String name); + + Object Evaluate(String expression); + + IXLCells FindCells(Func predicate); + + IXLColumns FindColumns(Func predicate); + + IXLRows FindRows(Func predicate); + + IXLNamedRange NamedRange(String rangeName); + + void Protect(Boolean lockStructure, Boolean lockWindows, String workbookPassword); + + void Protect(); + + void Protect(string workbookPassword); + + void Protect(Boolean lockStructure); + + void Protect(Boolean lockStructure, Boolean lockWindows); + + IXLRange Range(String range); + + IXLRange RangeFromFullAddress(String rangeAddress, out IXLWorksheet ws); + + IXLRanges Ranges(String ranges); + + /// + /// Saves the current workbook. + /// + void Save(); + + /// + /// Saves the current workbook and optionally performs validation + /// + void Save(Boolean validate, Boolean evaluateFormulae = false); + + void Save(SaveOptions options); + + /// + /// Saves the current workbook to a file. + /// + void SaveAs(String file); + + /// + /// Saves the current workbook to a file and optionally validates it. + /// + void SaveAs(String file, Boolean validate, Boolean evaluateFormulae = false); + + void SaveAs(String file, SaveOptions options); + + /// + /// Saves the current workbook to a stream. + /// + void SaveAs(Stream stream); + + /// + /// Saves the current workbook to a stream and optionally validates it. + /// + void SaveAs(Stream stream, Boolean validate, Boolean evaluateFormulae = false); + + void SaveAs(Stream stream, SaveOptions options); + + /// + /// Searches the cells' contents for a given piece of text + /// + /// The search text. + /// The compare options. + /// if set to true search formulae instead of cell values. + /// + IEnumerable Search(String searchText, CompareOptions compareOptions = CompareOptions.Ordinal, Boolean searchFormulae = false); + + XLWorkbook SetLockStructure(Boolean value); + + XLWorkbook SetLockWindows(Boolean value); + + XLWorkbook SetUse1904DateSystem(); + + XLWorkbook SetUse1904DateSystem(Boolean value); + + Boolean TryGetWorksheet(String name, out IXLWorksheet worksheet); + + void Unprotect(); + + void Unprotect(string workbookPassword); + + IXLWorksheet Worksheet(String name); + + IXLWorksheet Worksheet(Int32 position); + } +} diff --git a/ClosedXML/Excel/XLWorkbook.cs b/ClosedXML/Excel/XLWorkbook.cs index 5f73324..27ac919 100644 --- a/ClosedXML/Excel/XLWorkbook.cs +++ b/ClosedXML/Excel/XLWorkbook.cs @@ -41,7 +41,7 @@ Simple = 1, } - public partial class XLWorkbook: IDisposable + public partial class XLWorkbook: IXLWorkbook { #region Static