ExcelRow.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Biff8Excel.Interface;
  5. namespace Biff8Excel.Excel
  6. {
  7. /// <summary>
  8. /// Òѱ»ExcelCellLink´úÌæ
  9. /// </summary>
  10. public class ExcelRow : IDisposable
  11. {
  12. ushort m_iRowBlock;
  13. //Private arrCells(255) As ExcelCell ''' Array of column cells
  14. ExcelCell[] arrCells = new ExcelCell[256]; //Array of column cells
  15. ExcelCellStyle m_cellStyle;
  16. Biff8Excel.Records.Row m_row;
  17. ushort m_firstCol;
  18. ushort m_lastCol;
  19. ushort m_rowNumber;
  20. bool bfirstCol;
  21. bool blastCol;
  22. ushort m_sheetNumber;
  23. ushort m_styleIndex;
  24. int m_streamPosition;
  25. bool m_hidden;
  26. internal ExcelCell this[int index]
  27. {
  28. get
  29. {
  30. if (index == -1) return null;
  31. return arrCells[index];
  32. }
  33. }
  34. internal ushort FirstUsedCol
  35. {
  36. get { return m_firstCol; }
  37. }
  38. internal ushort LastUsedCol
  39. {
  40. get { return m_lastCol; }
  41. }
  42. internal ushort sheetNumber
  43. {
  44. set { m_sheetNumber = value; }
  45. }
  46. internal void AddCell(ushort iColumn, ExcelCell oCell)
  47. {
  48. arrCells[iColumn] = oCell; // add it to the column array
  49. }
  50. internal void SetFirstLastCol(ushort iColumn)
  51. {
  52. if (!bfirstCol)
  53. {
  54. m_firstCol = iColumn;
  55. bfirstCol = true;
  56. }
  57. else if (iColumn < m_firstCol)
  58. m_firstCol = iColumn;
  59. if (!blastCol)
  60. {
  61. m_lastCol = iColumn;
  62. blastCol = true;
  63. }
  64. else if (iColumn > m_lastCol)
  65. m_lastCol = (ushort)(iColumn + 1);
  66. }
  67. internal byte[] WriteRecord()
  68. {
  69. return m_row.GetByte();
  70. }
  71. public ExcelCellStyle Style
  72. {
  73. // used when retrieving value of a property, on the right side of an assignment.
  74. // Syntax: Debug.Print X.RowNumber
  75. get { return m_cellStyle; }
  76. }
  77. internal ushort rowNumber
  78. {
  79. // used when assigning a value to the property, on the left side of an assignment.
  80. // Syntax: X.RowNumber = 5
  81. set
  82. {
  83. m_rowNumber = value;
  84. m_row.RowNumber = (ushort)m_rowNumber;
  85. }
  86. // used when retrieving value of a property, on the right side of an assignment.
  87. // Syntax: Debug.Print X.RowNumber
  88. get { return (ushort)(m_rowNumber + 1); } //zero based idexing
  89. }
  90. internal ushort StyleIndex
  91. {
  92. // used when assigning a value to the property, on the left side of an assignment.
  93. // Syntax: X.RowNumber = 5
  94. set
  95. {
  96. m_styleIndex = value;
  97. m_row.ExtendedFormatIndex = value;
  98. }
  99. // used when assigning a value to the property, on the left side of an assignment.
  100. // Syntax: X.RowNumber = 5
  101. get { return m_styleIndex; }
  102. }
  103. public ushort Height
  104. {
  105. //'used when assigning a value to the property, on the left side of an assignment.
  106. //'Syntax: X.RowNumber = 5
  107. set { m_row.HeightInPoints = value; }
  108. get { return m_row.HeightInPoints; } //zero based indexing
  109. }
  110. public bool Hidden
  111. {
  112. //'used when assigning a value to the property, on the left side of an assignment.
  113. //'Syntax: X.RowNumber = 5
  114. set
  115. {
  116. m_hidden = value;
  117. m_row.Hidden = value; //zero based indexing
  118. }
  119. //'used when assigning a value to the property, on the left side of an assignment.
  120. //'Syntax: X.RowNumber = 5
  121. get { return m_hidden; } //zero based indexing
  122. }
  123. internal ushort RowBlock
  124. {
  125. get { return m_iRowBlock; }
  126. set { m_iRowBlock = value; }
  127. }
  128. internal bool AdditionalSpaceAbove
  129. {
  130. set { m_row.AdditionalSpaceAbove = value; }
  131. }
  132. internal bool AdditionalSpaceBelow
  133. {
  134. set { m_row.AdditionalSpaceBelow = value; }
  135. }
  136. internal int StreamPosition
  137. {
  138. set { m_streamPosition = value; }
  139. get { return m_streamPosition; }
  140. }
  141. public ExcelRow()
  142. {
  143. m_row = new Biff8Excel.Records.Row();
  144. m_cellStyle = new ExcelCellStyle();
  145. // default style
  146. m_cellStyle.Init();
  147. bfirstCol = false;
  148. blastCol = false;
  149. }
  150. #region IDisposable ³ÉÔ±
  151. public void Dispose()
  152. {
  153. m_row = null;
  154. m_cellStyle = null;
  155. }
  156. #endregion
  157. }
  158. }