Header.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 RecordHeader
  10. {
  11. public ushort opcode;
  12. public ushort length;
  13. public ushort textLen;
  14. [MarshalAs(UnmanagedType.U1, SizeConst = 1)] public byte zero;
  15. }
  16. internal class Header : IRecords
  17. {
  18. RecordHeader header;
  19. byte[] m_header;
  20. public Header()
  21. {
  22. header.opcode = 0x14;
  23. header.zero = 0x1;
  24. }
  25. public byte[] Head
  26. {
  27. set { m_header = value; }
  28. }
  29. public ushort TextLen
  30. {
  31. set { header.textLen = value; }
  32. }
  33. #region IRecords ³ÉÔ±
  34. public byte[] GetByte()
  35. {
  36. int len = 7 + m_header.Length;
  37. header.length = (ushort)(len - 4);
  38. //header.textLen = (ushort)(len - 7);
  39. byte[] b = new byte[len];
  40. Globals.GetStructToBytes(header).CopyTo(b, 0);
  41. m_header.CopyTo(b, 7);
  42. return b;
  43. }
  44. #endregion
  45. }
  46. }