MergedCells.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. internal struct StructMergedCells
  10. {
  11. public ushort mcFirstRow;
  12. public ushort mcLastRow;
  13. public ushort mcFirstCol;
  14. public ushort mcLastCol;
  15. }
  16. [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
  17. struct RecordMergedCells
  18. {
  19. public ushort opcode;
  20. public ushort length;
  21. public ushort total;
  22. }
  23. internal class MergedCells : IRecords
  24. {
  25. RecordMergedCells mergedcells;
  26. StructMergedCells[] structmergedcells;
  27. public MergedCells()
  28. {
  29. mergedcells.opcode = 0xE5;
  30. }
  31. public StructMergedCells[] SetMergedCells
  32. {
  33. set
  34. {
  35. try
  36. {
  37. mergedcells.total = (ushort)value.Length;
  38. structmergedcells = value;
  39. }
  40. catch
  41. {
  42. throw;
  43. }
  44. }
  45. }
  46. #region IRecords ³ÉÔ±
  47. public byte[] GetByte()
  48. {
  49. int len = 6 + (8 * mergedcells.total);
  50. byte[] b = new byte[len];
  51. mergedcells.length = (ushort)(len - 4);
  52. Globals.GetStructToBytes(mergedcells).CopyTo(b, 0);
  53. int pos = 6;
  54. for (int i = 0; i < mergedcells.total; i++, pos += 8)
  55. {
  56. Globals.GetStructToBytes(structmergedcells[i]).CopyTo(b, pos);
  57. }
  58. return b;
  59. }
  60. #endregion
  61. }
  62. }