// Generate a student grade report as a Word document. public void GenerateStudentReport(LocalStudent studentData, string reportPath) { // Ensure that the WordWrapper is disposed when the method finishes using (var wrapper = new WordWrapper()) { // Create a new Word document in memory wrapper.CreateBlankDocument(); // Add a heading to the document wrapper.AppendHeading(String.Format("Grade Report: {0} {1}", studentData.FirstName, studentData.LastName)); wrapper.InsertCarriageReturn(); wrapper.InsertCarriageReturn(); // Output the details of each grade for the student foreach (var grade in SessionContext.CurrentGrades) { // Use the IncludeProcessor to determine which fields in the Grade object are tagged List <FormatField> itemsToReport = IncludeProcessor.GetItemsToInclude(grade); // Output each tagged item, using the format specified by the properties of the IncludeInReport attribute for each item foreach (FormatField item in itemsToReport) { wrapper.AppendText(item.Label == string.Empty ? item.Value : item.Label + ": " + item.Value, item.IsBold, item.IsUnderlined); wrapper.InsertCarriageReturn(); } wrapper.InsertCarriageReturn(); } // Encrypt and save the Word document wrapper.EncryptAndSaveToDisk(reportPath); } }