using Org.BouncyCastle.Asn1.Mozilla; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using InABox.Core; namespace InABox.Scripting { public enum CellType { Formula, Numeric, Error, String, Boolean, Blank, Unknown, Date } public class CellRange { public int FirstRow { get; set; } public int LastRow { get; set; } public int FirstColumn { get; set; } public int LastColumn { get; set; } public CellRange(int firstRow, int lastRow, int firstColumn, int lastColumn) { FirstRow = firstRow; LastRow = lastRow; FirstColumn = firstColumn; LastColumn = lastColumn; } } public interface IDataFormat { public short FormatIndex { get; } } public enum UnderlineType { None, Single, Double, SingleAccounting, DoubleAccounting } public interface IFont { public bool Bold { get; set; } public bool Italic { get; set; } public UnderlineType Underline { get; set; } public double FontSize { get; set; } public Color Colour { get; } } public enum CellAlignment { Start, Middle, End, Justify } public interface ICellStyle { public ISpreadsheet Spreadsheet { get; } public IDataFormat DataFormat { get; set; } public IFont Font { get; } public Color Background { get; } public Color Foreground { get; } public CellAlignment VerticalAlignment { get; } public CellAlignment HorizontalAlignment { get; } public bool WrapText { get; } } public interface ISheet { public string Name { get; } int FirstRow { get; } int LastRow { get; } ISpreadsheet Spreadsheet { get; } IRow NewRow(); IRow? GetRow(int row); /// /// Sets the column width with a certain number of characters. /// /// /// /// ISheet SetColumnWidth(int column, float charWidth); /// /// Gets the width of a column in characters. Returns float.MinValue if no width has been set. /// /// /// float GetColumnWidth(int column); /// /// Gets the height of a row in points. /// /// /// float GetRowHeight(int row); float GetDefaultRowHeight(); ISheet MergeCells(int firstRow, int lastRow, int firstColumn, int lastColumn); IEnumerable GetMergedCells(); IEnumerable Rows(); IEnumerator RowEnumerator(); } public interface IRow { public int RowNumber { get; } int FirstColumn { get; } int LastColumn { get; } ISheet Sheet { get; } public ICell this[int column] { get { return GetCell(column); } } public string ExtractString(int column, bool uppercase = false); public DateTime ExtractDateTime(int column); public double? ExtractDouble(int column); public int GetColumn(string name, bool throwException = true); public ICell? GetCell(int column); public ICell NewCell(int column); public IEnumerable Cells(); } public interface ICell { IRow Row { get; } CellType GetCellType(); string GetValue(); bool? GetBoolValue(); double? GetDoubleValue(); DateTime GetDateTimeValue(); byte? GetByteValue(); ICell SetValue(bool value); ICell SetValue(string value); ICell SetValue(double value); ICell SetValue(DateTime value); ICell SetValue(byte value); ICell SetBlank(); ICellStyle GetStyle(); ICell SetStyle(ICellStyle style); } public interface ISpreadsheet { public ISheet GetSheet(int index); public ISheet GetSheet(string name); /// /// Make a new sheet and add it to the spreadsheet /// /// The name of the new sheet /// The new sheet public ISheet NewSheet(string name); /// /// Make a new sheet and add it to the spreadsheet /// /// The new sheet public ISheet NewSheet(); public IEnumerable Sheets(); public IEnumerator SheetEnumerator(); public ICellStyle NewStyle(); public IDataFormat GetDataFormat(string format); public void Write(FileStream file); public void Write(string filename, FileMode mode = FileMode.Create); } }