ExportTable.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Novacode;
  2. using System.Drawing;
  3. namespace Hotline.Share.Dtos.ExportWord
  4. {
  5. public class ExportTable : IWordElement
  6. {
  7. /// <summary>
  8. ///
  9. /// </summary>
  10. public List<ExportTableRow> Rows { get; set; } = new List<ExportTableRow>();
  11. /// <summary>
  12. ///
  13. /// </summary>
  14. public int RowCount => Rows.Count;
  15. /// <summary>
  16. ///
  17. /// </summary>
  18. public int ColumnCount { get; }
  19. /// <summary>
  20. ///
  21. /// </summary>
  22. public List<(int, int, int)> MergeCellsInColumns { get; } = new List<(int, int, int)>();
  23. /// <summary>
  24. ///
  25. /// </summary>
  26. public List<(int, int, int)> MergeCellsInRows { get; } = new List<(int, int, int)>();
  27. public ExportTable()
  28. {
  29. }
  30. public ExportTable(int rowCount, int columnCount)
  31. {
  32. ColumnCount = columnCount;
  33. for (int i = 0; i < rowCount; i++)
  34. {
  35. ExportTableRow fWTableRow = new ExportTableRow();
  36. for (int j = 0; j < columnCount; j++)
  37. {
  38. ExportTableCell item = new ExportTableCell
  39. {
  40. Paragraphs = new List<ExportParagraph>
  41. {
  42. new ExportParagraph
  43. {
  44. Run = new ExportRun()
  45. }
  46. }
  47. };
  48. fWTableRow.Cells.Add(item);
  49. }
  50. Rows.Add(fWTableRow);
  51. }
  52. }
  53. public void MergeCellsInColumn(int columnIndex, int startRow, int endRow)
  54. {
  55. MergeCellsInColumns.Add((columnIndex, startRow, endRow));
  56. }
  57. public void MergeCellsInRow(int rowIndex, int startColumn, int endColumn)
  58. {
  59. MergeCellsInRows.Add((rowIndex, startColumn, endColumn));
  60. }
  61. }
  62. public class ExportTableCell
  63. {
  64. /// <summary>
  65. ///
  66. /// </summary>
  67. public List<ExportParagraph> Paragraphs { get; set; }
  68. /// <summary>
  69. ///
  70. /// </summary>
  71. public double Width { get; set; } = 200.0;
  72. /// <summary>
  73. ///
  74. /// </summary>
  75. public Color FillColor { get; set; } = Color.Empty;
  76. /// <summary>
  77. ///
  78. /// </summary>
  79. public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Center;
  80. }
  81. public class ExportTableRow
  82. {
  83. /// <summary>
  84. ///
  85. /// </summary>
  86. public List<ExportTableCell> Cells { get; set; } = new List<ExportTableCell>();
  87. /// <summary>
  88. ///
  89. /// </summary>
  90. public double Height { get; set; }
  91. }
  92. public class ExportText : IWordElement
  93. {
  94. /// <summary>
  95. ///
  96. /// </summary>
  97. public string Data { get; set; }
  98. }
  99. }