ExternSheet.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 StructExternSheet
  10. {
  11. public ushort tIndex; // for our purposes will always be zero, index to first supbook record
  12. public ushort tFirstSheet;
  13. public ushort tLastSheet;
  14. }
  15. [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
  16. struct RecordExternSheet
  17. {
  18. public ushort opcode;
  19. public ushort length;
  20. public ushort num;
  21. }
  22. internal class ExternSheet : IRecords
  23. {
  24. RecordExternSheet externsheet;
  25. StructExternSheet[] structs;
  26. public ExternSheet()
  27. {
  28. externsheet.opcode = 0x17;
  29. }
  30. public StructExternSheet[] ExternSheets
  31. {
  32. set
  33. {
  34. try
  35. {
  36. if (value == null)
  37. externsheet.num = 0;
  38. else
  39. externsheet.num = (ushort)value.Length;
  40. structs = value;
  41. }
  42. catch
  43. {
  44. throw;
  45. }
  46. }
  47. }
  48. #region IRecords ³ÉÔ±
  49. public byte[] GetByte()
  50. {
  51. byte[] b;
  52. ushort length;
  53. if (externsheet.num == 0)
  54. return null;
  55. length = (ushort)(6 + (6 & externsheet.num));
  56. b = new byte[length];
  57. externsheet.length = (ushort)(length - 4);
  58. Globals.GetStructToBytes(externsheet).CopyTo(b, 0);
  59. int pos = 6;
  60. for (int i = 0; i < structs.Length; i++, pos += 6)
  61. {
  62. Globals.GetStructToBytes(structs[i]).CopyTo(b, pos);
  63. }
  64. return b;
  65. }
  66. #endregion
  67. }
  68. }