| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 | 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);        /// <summary>        /// Sets the column width with a certain number of characters.        /// </summary>        /// <param name="column"></param>        /// <param name="charWidth"></param>        /// <returns></returns>        ISheet SetColumnWidth(int column, float charWidth);        /// <summary>        /// Gets the width of a column in characters. Returns float.MinValue if no width has been set.        /// </summary>        /// <param name="column"></param>        /// <returns></returns>        float GetColumnWidth(int column);        /// <summary>        /// Gets the height of a row in points.        /// </summary>        /// <param name="row"></param>        /// <returns></returns>        float GetRowHeight(int row);        float GetDefaultRowHeight();        ISheet MergeCells(int firstRow, int lastRow, int firstColumn, int lastColumn);        IEnumerable<CellRange> GetMergedCells();        IEnumerable<IRow> Rows();        IEnumerator<IRow> 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<ICell> 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);        /// <summary>        /// Make a new sheet and add it to the spreadsheet        /// </summary>        /// <param name="name">The name of the new sheet</param>        /// <returns>The new sheet</returns>        public ISheet NewSheet(string name);        /// <summary>        /// Make a new sheet and add it to the spreadsheet        /// </summary>        /// <returns>The new sheet</returns>        public ISheet NewSheet();        public IEnumerable<ISheet> Sheets();        public IEnumerator<ISheet> SheetEnumerator();        public ICellStyle NewStyle();        public IDataFormat GetDataFormat(string format);        public void Write(FileStream file);        public void Write(string filename, FileMode mode = FileMode.Create);    }}
 |