ISheet.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace InABox.Scripting
  8. {
  9. public interface IDataFormat {
  10. public short FormatIndex { get; }
  11. }
  12. public interface ICellStyle
  13. {
  14. public IDataFormat DataFormat { get; set; }
  15. }
  16. public interface ISheet
  17. {
  18. public string Name { get; }
  19. IRow NewRow();
  20. /// <summary>
  21. /// Sets the column width with a certain number of characters
  22. /// </summary>
  23. /// <param name="column"></param>
  24. /// <param name="charWidth"></param>
  25. /// <returns></returns>
  26. ISheet SetColumnWidth(int column, float charWidth);
  27. ISheet MergeCells(int firstRow, int lastRow, int firstColumn, int lastColumn);
  28. IEnumerable<IRow> Rows();
  29. IEnumerator<IRow> RowEnumerator();
  30. }
  31. public interface IRow
  32. {
  33. public int RowNumber { get; }
  34. public ICell this[int column]
  35. {
  36. get { return GetCell(column); }
  37. }
  38. public string ExtractString(int column, bool uppercase = false);
  39. public DateTime ExtractDateTime(int column);
  40. public double? ExtractDouble(int column);
  41. public int GetColumn(string name, bool throwException = true);
  42. public ICell GetCell(int column);
  43. public ICell NewCell(int column);
  44. }
  45. public interface ICell
  46. {
  47. string GetValue();
  48. bool? GetBoolValue();
  49. double? GetDoubleValue();
  50. DateTime GetDateTimeValue();
  51. byte? GetByteValue();
  52. ICell SetValue(bool value);
  53. ICell SetValue(string value);
  54. ICell SetValue(double value);
  55. ICell SetValue(DateTime value);
  56. ICell SetValue(byte value);
  57. ICell SetBlank();
  58. ICell SetStyle(ICellStyle style);
  59. }
  60. public interface ISpreadsheet
  61. {
  62. public ISheet GetSheet(int index);
  63. public ISheet GetSheet(string name);
  64. /// <summary>
  65. /// Make a new sheet and add it to the spreadsheet
  66. /// </summary>
  67. /// <param name="name">The name of the new sheet</param>
  68. /// <returns>The new sheet</returns>
  69. public ISheet NewSheet(string name);
  70. /// <summary>
  71. /// Make a new sheet and add it to the spreadsheet
  72. /// </summary>
  73. /// <returns>The new sheet</returns>
  74. public ISheet NewSheet();
  75. public IEnumerable<ISheet> Sheets();
  76. public IEnumerator<ISheet> SheetEnumerator();
  77. public ICellStyle NewStyle();
  78. public IDataFormat GetDataFormat(string format);
  79. public void Write(FileStream file);
  80. public void Write(string filename, FileMode mode = FileMode.Create);
  81. }
  82. }