INdex.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5. using Biff8Excel.Interfaces;
  6. namespace Biff8Excel.Records
  7. {
  8. [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
  9. struct RecordINdex
  10. {
  11. public ushort opcode;
  12. public ushort length;
  13. public uint notUsed;
  14. public uint firstrowUsed; //zero based
  15. public uint lastRowUsedplus; //zero based
  16. public uint defColOffset;
  17. }
  18. internal class INdex : IRecords
  19. {
  20. RecordINdex index;
  21. int m_NumberOfRowBlocks;
  22. uint[] m_RowBlockOffsets;
  23. public INdex()
  24. {
  25. index.opcode = 0x20B;
  26. index.firstrowUsed = 0x0;
  27. index.lastRowUsedplus = 0x0;
  28. }
  29. public ushort ID
  30. {
  31. get {return index.opcode;}
  32. }
  33. public ushort RecordSize
  34. {
  35. get { return (ushort)(20 + 4 * m_NumberOfRowBlocks);}
  36. }
  37. public uint FirstRowIndex
  38. {
  39. set { index.firstrowUsed = value; }
  40. }
  41. public uint LastRowIndex
  42. {
  43. set { index.lastRowUsedplus = value; }
  44. }
  45. public uint DefColumnRecordOffset
  46. {
  47. set { index.defColOffset = value; }
  48. }
  49. public uint[] DBCellOffsets
  50. //public List<int> DBCellOffsets
  51. {
  52. set
  53. {
  54. //m_NumberOfRowBlocks = (int)value.Length;
  55. m_NumberOfRowBlocks = value.Length;
  56. m_RowBlockOffsets = value;
  57. }
  58. }
  59. #region IRecords ³ÉÔ±
  60. public byte[] GetByte()
  61. {
  62. byte[] b;
  63. int ln = 20 + (4 * m_NumberOfRowBlocks);
  64. b = new byte[ln];
  65. index.length = (ushort)(ln - 4);
  66. Globals.GetStructToBytes(index).CopyTo(b, 0);
  67. int pos = 20;
  68. for (int i = 0; i < m_NumberOfRowBlocks; i++, pos += 4)
  69. {
  70. BitConverter.GetBytes(m_RowBlockOffsets[i]).CopyTo(b, pos);
  71. }
  72. return b;
  73. }
  74. #endregion
  75. }
  76. }