public void Process() { using(SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(@"D:\product.xlsx", SpreadsheetDocumentType.Workbook)) { var excelExportContext = new ExportContext(spreadsheetDocument); uint rowNo = 0; foreach(var product in _products) { rowNo++; if(product.Price > 44) { product.MapColumn<Product>(x => x.Description, "F"); product.MapStyle<Product>(x => x.Name, new CellFill(hexColor: "FFFF0000")); } if(product.Price < 33) { product.MapStyle<Product>(x => x.Code, new CellBorder(left: true, right: true)); } excelExportContext.RenderEntity(product, rowNo); } excelExportContext.SaveChanges(); } }
public void Process() { using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(@"D:\product.xlsx", SpreadsheetDocumentType.Workbook)) { var excelExportContext = new ExportContext(spreadsheetDocument); uint rowNo = 0; foreach (var product in _products) { rowNo++; if (product.Price > 44) { product.MapColumn <Product>(x => x.Description, "F"); product.MapStyle <Product>(x => x.Name, new CellFill(hexColor: "FFFF0000")); } if (product.Price < 33) { product.MapStyle <Product>(x => x.Code, new CellBorder(left: true, right: true)); } excelExportContext.RenderEntity(product, rowNo); } excelExportContext.SaveChanges(); } }