ExcelCellLink.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Collections;
  5. namespace Biff8Excel.Excel
  6. {
  7. /// <summary>
  8. /// 每一行所有有内容ExcelCell的链
  9. /// key 为列号从零开始1,2,3,4无数据跳过
  10. /// </summary>
  11. public class ExcelCellLinkDictionary : SortedList<ushort,ExcelCell> // BaseTwoLinkList<ExcelCell>
  12. {
  13. //ushort m_iRowBlock;
  14. //ushort m_sheetNumber;
  15. ushort m_styleIndex;
  16. //int m_streamPosition;
  17. bool m_hidden;
  18. Biff8Excel.Records.Row m_row;
  19. ExcelCellStyle m_cellStyle;
  20. //ushort m_rowNumber;
  21. internal bool AdditionalSpaceAbove
  22. {
  23. set { m_row.AdditionalSpaceAbove = value; }
  24. }
  25. internal bool AdditionalSpaceBelow
  26. {
  27. set { m_row.AdditionalSpaceBelow = value; }
  28. }
  29. public ExcelCellLinkDictionary(ExcelWorkbook pWorkbook)
  30. : base()
  31. {
  32. m_row = new Biff8Excel.Records.Row();
  33. //m_cellStyle = new ExcelCellStyle(pWorkbook);
  34. m_cellStyle = pWorkbook.CreateStyle();
  35. // default style
  36. //m_cellStyle.Init();
  37. m_cellStyle.RowsInit();
  38. this.StyleIndex = m_cellStyle.GetXFIndex();
  39. }
  40. public ushort Height
  41. {
  42. //'used when assigning a value to the property, on the left side of an assignment.
  43. //'Syntax: X.RowNumber = 5
  44. set { m_row.HeightInPoints = value; }
  45. get { return m_row.HeightInPoints; } //zero based indexing
  46. }
  47. public bool Hidden
  48. {
  49. //'used when assigning a value to the property, on the left side of an assignment.
  50. //'Syntax: X.RowNumber = 5
  51. set
  52. {
  53. m_hidden = value;
  54. m_row.Hidden = value; //zero based indexing
  55. }
  56. //'used when assigning a value to the property, on the left side of an assignment.
  57. //'Syntax: X.RowNumber = 5
  58. get { return m_hidden; } //zero based indexing
  59. }
  60. //internal ushort RowBlock
  61. //{
  62. // //get { return m_iRowBlock; }
  63. // set { m_iRowBlock = value; }
  64. //}
  65. internal ushort rowNumber
  66. {
  67. // used when assigning a value to the property, on the left side of an assignment.
  68. // Syntax: X.RowNumber = 5
  69. set
  70. {
  71. //m_rowNumber = value;
  72. m_row.RowNumber = value;
  73. }
  74. // used when retrieving value of a property, on the right side of an assignment.
  75. // Syntax: Debug.Print X.RowNumber
  76. //get { return (ushort)(m_rowNumber + 1); } //zero based idexing
  77. }
  78. ExcelCell oc;
  79. internal void SetCell(ushort Column, ExcelCell ocell)
  80. {
  81. if (this.TryGetValue(Column, out oc))
  82. oc = ocell;
  83. else
  84. this.AddCell(Column, ocell);
  85. }
  86. internal void AddCell(ushort Column, ExcelCell ocell)
  87. {
  88. this.Add(Column, ocell);
  89. }
  90. //internal ushort sheetNumber
  91. //{
  92. // set { m_sheetNumber = value; }
  93. //}
  94. //internal int StreamPosition
  95. //{
  96. // //set { m_streamPosition = value; }
  97. // //get { return m_streamPosition; }
  98. //}
  99. public ExcelCellStyle Style
  100. {
  101. // used when retrieving value of a property, on the right side of an assignment.
  102. // Syntax: Debug.Print X.RowNumber
  103. internal get { return m_cellStyle; }
  104. set
  105. {
  106. m_cellStyle = value;
  107. this.StyleIndex = value.GetXFIndex();
  108. }
  109. }
  110. internal ushort StyleIndex
  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_styleIndex = value;
  117. m_row.ExtendedFormatIndex = value;
  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_styleIndex; }
  122. }
  123. internal byte[] WriteRecord()
  124. {
  125. return m_row.GetByte();
  126. }
  127. }
  128. }