1 2 И 3 сдано
This commit is contained in:
parent
f98f8af0ab
commit
b73076b5b7
@ -42,7 +42,7 @@ namespace COPWinForms
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateTable(TableWord tableWord)
|
||||
public void CreateTable<T>(TableWord<T> tableWord) where T : class
|
||||
{
|
||||
// Проверка наличия данных и определений столбцов
|
||||
if (tableWord.Data == null)
|
||||
@ -79,7 +79,7 @@ namespace COPWinForms
|
||||
{
|
||||
|
||||
builder.InsertCell();
|
||||
// builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(tableWord.WeightColumn[ColInd1]);
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Width);
|
||||
builder.Write(columnDefinition.Header);
|
||||
|
||||
ColInd1++;
|
||||
@ -114,7 +114,7 @@ namespace COPWinForms
|
||||
{
|
||||
|
||||
builder.InsertCell();
|
||||
// builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(tableWord.WeightColumn[ColInd]);
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Width);
|
||||
builder.Write(columnDefinition2.Header);
|
||||
|
||||
ColInd++;
|
||||
|
@ -7,15 +7,15 @@ using static COPWinForms.ComponentWord2;
|
||||
|
||||
namespace COPWinForms
|
||||
{
|
||||
public class TableWord
|
||||
public class TableWord<T> where T : class
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
public string DocumentTitle = string.Empty;
|
||||
public List<ColumnDefinition> ColumnDefinitions;
|
||||
public List<ColumnDefinition> ColumnDefinitions2;
|
||||
public List<object> Data;
|
||||
public List<T> Data;
|
||||
public List<int[]> MergedColumns;
|
||||
public TableWord(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<object> data, List<int[]> mergedColumns)
|
||||
public TableWord(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<T> data, List<int[]> mergedColumns)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
|
@ -170,7 +170,7 @@ namespace WinFormsTest
|
||||
new ColumnDefinition { Header = "Group", PropertyName = "Group", Width = 21 }
|
||||
};
|
||||
|
||||
List<object> data = new List<object>
|
||||
List<Student> data = new List<Student>
|
||||
{
|
||||
new Student { FIO = "John", Group = "Group1", Email = "email1@email" },
|
||||
new Student { FIO = "Jane", Group = "Group2", Email = "email2@email" },
|
||||
@ -186,7 +186,7 @@ namespace WinFormsTest
|
||||
{
|
||||
try
|
||||
{
|
||||
TableWord tableWord = new(dialog.FileName, "Çàäàíèå 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
|
||||
TableWord<Student> tableWord = new(dialog.FileName, "Çàäàíèå 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
|
||||
componentWord21.CreateTable(tableWord);
|
||||
MessageBox.Show("Ôàéë ñîçäàí", "Ðåçóëüòàò", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user