Format.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 RecordFormat
  10. {
  11. public ushort opcode;
  12. public ushort length;
  13. public ushort index;
  14. public ushort formatlen;
  15. }
  16. internal class Format : IRecords
  17. {
  18. RecordFormat format;
  19. byte[] m_strings;
  20. //int m_formatlen;
  21. public Format()
  22. {
  23. format.opcode = 0x41E;
  24. }
  25. public ushort Index
  26. {
  27. set {format.index = value;}
  28. }
  29. public string FormatString
  30. {
  31. set
  32. {
  33. m_strings = Globals.GetDefaultBytes(value);
  34. format.formatlen = (ushort)m_strings.Length;
  35. }
  36. }
  37. public ushort ID
  38. {
  39. get {return format.opcode;}
  40. }
  41. public ushort RecordSize
  42. {
  43. get {return (ushort)(9 + format.formatlen) ; }
  44. }
  45. #region IRecords ³ÉÔ±
  46. public byte[] GetByte()
  47. {
  48. byte[] b;
  49. int len = 9 + format.formatlen;
  50. b = new byte[len];
  51. format.length = (ushort)(len - 4);
  52. Globals.GetStructToBytes(format).CopyTo(b, 0);
  53. b[8] = 0;
  54. m_strings.CopyTo(b, 9);
  55. return b;
  56. }
  57. #endregion
  58. }
  59. }