|
@@ -13,6 +13,7 @@ using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Shapes;
|
|
|
using Excel = Microsoft.Office.Interop.Excel;
|
|
|
+using Word = Microsoft.Office.Interop.Word;
|
|
|
|
|
|
namespace ROGOZ.Pages
|
|
|
{
|
|
@@ -155,5 +156,61 @@ namespace ROGOZ.Pages
|
|
|
}
|
|
|
application.Visible = true;
|
|
|
}
|
|
|
+
|
|
|
+ private void btnWord_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ var allTask = _context.Task.ToList();
|
|
|
+ var allExecuters = _context.Executor.ToList();
|
|
|
+
|
|
|
+ var application = new Word.Application();
|
|
|
+
|
|
|
+ Word.Document document = application.Documents.Add();
|
|
|
+
|
|
|
+ foreach (var ex in allExecuters)
|
|
|
+ {
|
|
|
+ Word.Paragraph executerParagraph = document.Paragraphs.Add();
|
|
|
+ Word.Range executerRange = executerParagraph.Range;
|
|
|
+ executerRange.Text = ex.User.MiddleName;
|
|
|
+ executerParagraph.set_Style("Заголовок");
|
|
|
+ executerRange.InsertParagraphAfter();
|
|
|
+
|
|
|
+
|
|
|
+ Word.Paragraph tableParagraph = document.Paragraphs.Add();
|
|
|
+ Word.Range tableRange = tableParagraph.Range;
|
|
|
+ Word.Table tasksTable = document.Tables.Add(tableRange,
|
|
|
+ allExecuters.Count(), 3);
|
|
|
+ tasksTable.Borders.InsideLineStyle = tasksTable.Borders.OutsideLineStyle
|
|
|
+ = Word.WdLineStyle.wdLineStyleSingle;
|
|
|
+ tasksTable.Range.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
|
|
|
+
|
|
|
+ Word.Range cellRange;
|
|
|
+
|
|
|
+ cellRange = tasksTable.Cell(1, 1).Range;
|
|
|
+ cellRange.Text = "Название задачи";
|
|
|
+ cellRange = tasksTable.Cell(1, 2).Range;
|
|
|
+ cellRange.Text = "Крайняя дата задачи";
|
|
|
+ cellRange = tasksTable.Cell(1, 3).Range;
|
|
|
+ cellRange.Text = "Статус";
|
|
|
+
|
|
|
+ tasksTable.Rows[1].Range.Bold = 1;
|
|
|
+ tasksTable.Rows[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
|
|
|
+
|
|
|
+ for (int i = 1; i < allExecuters.Count(); i++)
|
|
|
+ {
|
|
|
+ cellRange = tasksTable.Cell(i + 2, 1).Range;
|
|
|
+ cellRange.Text = allTask[i].Title;
|
|
|
+
|
|
|
+ cellRange = tasksTable.Cell(i + 2, 2).Range;
|
|
|
+ cellRange.Text = allTask[i].Deadline.ToString();
|
|
|
+
|
|
|
+ cellRange = tasksTable.Cell(i + 2, 3).Range;
|
|
|
+ cellRange.Text = allTask[i].Status;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ex != allExecuters.LastOrDefault())
|
|
|
+ document.Words.Last.InsertBreak(Word.WdBreakType.wdPageBreak);
|
|
|
+ }
|
|
|
+ application.Visible = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|