public List <Row> EmptyRows(object list, RowPropertyOptions options, int count = 1) { List <Row> rows = new(); for (int i = 0; i < count; i++) { rows.Add(EmptyRow(list, options)); } return(rows); }
private Row EmptyRow(object list, RowPropertyOptions options) { if (list is IEnumerable cells) { var location = new Location(options.StartLocation.X, options.StartLocation.Y); Row row = new(); foreach (var cell in cells) { row.Cells.Add(AddCell(string.Empty, string.Empty, new CellsPropertyOptions(new Location(location.X, location.Y)))); location.X++; } return(row); } return(null); }
/// <summary> /// Cells is "List" of any Objects /// </summary> /// <param name="list"></param> /// <returns></returns> public Row AddRow(object list, RowPropertyOptions options, int emptyCells = 0) { if (list is IEnumerable cells) { Row row = new(); var location = new Location(options.StartLocation.X, options.StartLocation.Y); foreach (var cell in cells) { if (cell is string) { row.Cells.Add(AddCell(cell, "", new CellsPropertyOptions(new Location(location.X, location.Y)))); location.X++; } else { PropertyInfo[] props = cell.GetType().GetProperties(); foreach (PropertyInfo prop in props) { if (cell != null) { var att = prop.GetCustomAttributes(true).Where(x => x is ExcelReportAttribute).FirstOrDefault(); if (att is ExcelReportAttribute attr) { if (attr.Visible != false) { row.Cells.Add(AddCell(cell, prop.Name, new CellsPropertyOptions(new Location(location.X, location.Y)))); location.X++; } } else { row.Cells.Add(AddCell(cell, prop.Name, new CellsPropertyOptions(new Location(location.X, location.Y)))); location.X++; } } } } for (int i = 0; i < emptyCells; i++) { row.Cells.Add(AddCell("", "", new CellsPropertyOptions(new Location(location.X, location.Y)))); location.X++; } } return(row); } return(null); }