public void WriteToFile(GroupMarksReport information, string path) { if (information == null || path == null) { throw new ArgumentNullException(); } var excelFile = new FileInfo(path); using ExcelPackage package = new ExcelPackage(excelFile); if (package.Workbook.Worksheets.Count(worksheet => worksheet.Name == typeof(SummaryMarkInfo).Name) > 0) { package.Workbook.Worksheets.Delete(typeof(SummaryMarkInfo).Name); } var worksheet = package.Workbook.Worksheets.Add(typeof(SummaryMarkInfo).Name); var range = worksheet.Cells[1, 1]; range.LoadFromCollection(information.StudentAvegareInfos, true); range.AutoFitColumns(); var lastRow = worksheet.Dimension.End.Row; range = worksheet.Cells[lastRow + rowOffset, 1]; range.LoadFromCollection(information.SummaryMarkInfo.AverageMarks, true); package.Save(); }
public void WriteToFile(GroupMarksReport information, string path) { if (information == null || path == null) { throw new ArgumentNullException(); } var options = new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) }; string serializedCollection = JsonSerializer.Serialize(information, options); using var writer = new StreamWriter(path); writer.Write(serializedCollection); }
public void WriteRecord(string outputFile, IEnumerable <StudentMarksInfo> studentInfos) { if (outputFile == null || outputFile == string.Empty) { throw new ArgumentNullException(nameof(outputFile)); } if (studentInfos == null) { throw new ArgumentNullException(nameof(studentInfos)); } var studentTotals = studentInfos.CastToStudentAvegareInfo(); var summaryMarkInfo = studentInfos.CastToSummaryMarkInfo(); var groupReport = new GroupMarksReport() { SummaryMarkInfo = summaryMarkInfo, StudentAvegareInfos = studentTotals.ToList().AsReadOnly() }; writer.WriteToFile(groupReport, outputFile); }