public void SaveFile(string path) { Workbook workbook = new Workbook(); workbook.Add(sheet); workbook.Save(path); }
static void Main(string[] args) { var wb = new Workbook(); wb.Title = "Workbook Title"; wb.Author = "The Author"; var sheet = new Worksheet("Test"); sheet.PageSetup.Orientation = Orientation.Landscape; sheet.PageSetup.PrintRepeatRows = 2; sheet.PageSetup.PrintRepeatColumns = 2; sheet.ColumnWidths[0] = 24.6; sheet.Cells["A1"] = "Test"; sheet.Cells["A1"].FontName = "Arial Black"; sheet.Cells[0, 1] = "Another Test"; sheet.Cells[0, 1].Border = CellBorder.Bottom | CellBorder.Right; sheet.Cells[0, 2] = "Bold Red"; sheet.Cells[0, 2].Bold = true; sheet.Cells[0, 2].TextColor = Color.Red; Cell cell = "BIU Big Blue"; cell.Bold = true; cell.Underline = true; cell.Italic = true; cell.TextColor = Color.Blue; cell.FontSize = 18; cell.Hyperlink = "https://github.com/mstum/Simplexcel"; sheet.Cells[0, 3] = cell; sheet.ColumnWidths[3] = 40; sheet.Cells[0, 4] = 13; sheet.Cells[0, 5] = 13.58; for (int i = 1; i < 55; i++) { sheet.Cells[1, i] = Guid.NewGuid().ToString("N"); sheet.Cells[i, 0] = Guid.NewGuid().ToString("N"); } Cell cell2 = "Orange"; cell2.Bold = true; cell2.Italic = true; cell2.TextColor = Color.Orange; cell2.FontSize = 18; sheet.Cells[0, 2] = cell2; wb.Add(sheet); wb.Save(@"testCompressed.xlsx", CompressionLevel.Maximum); wb.Save(@"testUncompressed.xlsx", CompressionLevel.NoCompression); }
public override void Process(iExcel owner, ref Workbook book, ref Worksheet sheet) { try { if (book != null && !string.IsNullOrEmpty(Title)) { sheet = new Worksheet(Title); //sheet.PageSetup.PrintRepeatRows = 2; //sheet.PageSetup.PrintRepeatColumns = 2; if (Style != null) { if (Style["Orientation"] != null) { if (((string)Style["Orientation"]).ToLower() == "landscape") { sheet.PageSetup.Orientation = Orientation.Landscape; } else if (((string)Style["Orientation"]).ToLower() == "portrait") { sheet.PageSetup.Orientation = Orientation.Portrait; } } } book.Add(sheet); } } catch (Exception ex) { Log.Trace(ex.Message, ex.StackTrace); } }
static Workbook CreateWorkbook(params Worksheet[] sheets) { var workbook = new Workbook(); foreach (Worksheet sheet in sheets) { workbook.Add(sheet); } return(workbook); }
static void Main(string[] args) { var wb = new Workbook(); wb.Title = "Workbook Title"; wb.Author = "The Author"; var sheet = new Worksheet("Test"); sheet.PageSetup.Orientation = Orientation.Landscape; sheet.PageSetup.PrintRepeatRows = 2; sheet.PageSetup.PrintRepeatColumns = 2; sheet.ColumnWidths[0] = 24.6; sheet.Cells["A1"] = "Test"; sheet.Cells["A1"].FontName = "Arial Black"; sheet.Cells[0, 1] = "Another Test"; sheet.Cells[0, 1].Border = CellBorder.Bottom | CellBorder.Right; sheet.Cells[0, 2] = "Bold Red"; sheet.Cells[0, 2].Bold = true; sheet.Cells[0, 2].TextColor = Color.Red; Cell cell = "BIU Big Blue"; cell.Bold = true; cell.Underline = true; cell.Italic = true; cell.TextColor = Color.Blue; cell.FontSize = 18; cell.Hyperlink = "https://github.com/mstum/Simplexcel"; sheet.Cells[0, 3] = cell; sheet.ColumnWidths[3] = 40; sheet.Cells[0, 4] = 13; sheet.Cells[0, 5] = 13.58; for (int i = 1; i < 55; i++) { sheet.Cells[1,i] = Guid.NewGuid().ToString("N"); sheet.Cells[i,0] = Guid.NewGuid().ToString("N"); } Cell cell2 = "Orange"; cell2.Bold = true; cell2.Italic = true; cell2.TextColor = Color.Orange; cell2.FontSize = 18; sheet.Cells[0, 2] = cell2; wb.Add(sheet); wb.Save(@"testCompressed.xlsx", CompressionLevel.Maximum); wb.Save(@"testUncompressed.xlsx", CompressionLevel.NoCompression); }
/// <summary>Creates a new Worksheet.</summary> /// <param name="data">The data.</param> /// <param name="workbook">The workbook.</param> /// <param name="sheetName">Name of the sheet.</param> /// <param name="orientation">The orientation.</param> internal void WorkSheet_New(pcExcelData_ data, Workbook workbook, string sheetName, enExcel_Orientation orientation = enExcel_Orientation.Portrait) { var sheet = new Worksheet(sheetName); workbook.Add(sheet); sheet.PageSetup.Orientation = (enOrientation)orientation; sheet.PageSetup.PrintRepeatRows = 2; sheet.PageSetup.PrintRepeatColumns = 2; data._sheet = sheet; }
public void WorkbookWithSheet_Serializes() { var wb = new Workbook(); var ws = new Worksheet("Test"); wb.Add(ws); var cloned = Clone(wb); Assert.Equal(1, cloned.Sheets.Count()); Assert.Equal("Test", cloned.Sheets.First().Name); }
public void ProcessRequest(HttpContext context) { // Create Excel Sheet var sheet = new Worksheet("Hello, world!"); sheet.Cells[0, 0] = "Hello,"; sheet.Cells["B1"] = "World!"; var workbook = new Workbook(); workbook.Add(sheet); // Save Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("Content-Disposition", "attachment; filename=MyExcelSheet.xls"); workbook.Save(Response.OutputStream, CompressionLevel.Maximum); }
private static byte[] CreateExcel() { var workBook = new Workbook(); for (int i = 0; i < 100; i++) { if (i % 25 > 0) { Console.WriteLine("Adding code to page"); } else { workBook.Add(new Worksheet("page : " + i)); } } using (var ms = new MemoryStream()) { workBook.Save(ms); return(ms.ToArray()); } }
static void Main(string[] args) { var wb = new Workbook(); wb.Title = "Workbook Title"; wb.Author = "The Author"; var sheet = new Worksheet("Test"); sheet.PageSetup.Orientation = Orientation.Landscape; sheet.PageSetup.PrintRepeatRows = 2; sheet.PageSetup.PrintRepeatColumns = 2; sheet.ColumnWidths[0] = 24.6; sheet.Cells["A1"] = "Test"; sheet.Cells["A1"].FontName = "Arial Black"; sheet.Cells[0, 1] = "Another Test"; sheet.Cells[0, 1].Border = CellBorder.Bottom | CellBorder.Right; sheet.Cells[0, 2] = "Bold Red"; sheet.Cells[0, 2].Bold = true; sheet.Cells[0, 2].TextColor = Color.Red; Cell cell = "BIU & Big & Blue"; cell.Bold = true; cell.Underline = true; cell.Italic = true; cell.TextColor = Color.Blue; cell.FontSize = 18; cell.Hyperlink = "https://github.com/mstum/Simplexcel"; sheet.Cells[0, 3] = cell; sheet.ColumnWidths[3] = 40; sheet.Cells[0, 4] = 13; sheet.Cells[0, 5] = 13.58; for (int i = 1; i < 55; i++) { sheet.Cells[1, i] = Guid.NewGuid().ToString("N"); sheet.Cells[i, 0] = Guid.NewGuid().ToString("N"); } Cell cell2 = "Orange"; cell2.Bold = true; cell2.Italic = true; cell2.TextColor = Color.Orange; cell2.FontSize = 18; sheet.Cells[0, 2] = cell2; // Note that Emoji only work in Excel 2013 or newer, not 2007 or 2010. This is an Excel limitation. sheet.Cells[0, 6] = "👪"; sheet.Cells[0, 7] = "👨👩👧👦"; sheet.Cells["D4"] = DateTime.Now; sheet.Cells["D5"] = new Cell(CellType.Date, DateTime.Now, BuiltInCellFormat.DateOnly); sheet.Cells["D6"] = new Cell(CellType.Date, DateTime.Now, BuiltInCellFormat.TimeOnly); sheet.Cells["D7"] = long.MaxValue; sheet.Cells["D8"] = long.MinValue; sheet.Cells["D9"] = decimal.MaxValue; sheet.Cells["D10"] = decimal.MinValue; sheet.Cells["D11"] = 9999999999L; sheet.Cells["D12"] = 99999999999L; sheet.Cells["D13"] = 100000000000L; sheet.Cells["D14"] = 100000000001L; sheet.Cells["D15"] = 1000000000000L; sheet.Cells["D16"] = 1000000000001L; sheet.Cells["D17"] = Cell.LargeNumberPositiveLimit; sheet.Cells["D18"] = Cell.LargeNumberPositiveLimit + 1; sheet.Cells["D19"] = Cell.LargeNumberPositiveLimit - 1; sheet.Cells["D20"] = -9999999999L; sheet.Cells["D21"] = -99999999999L; sheet.Cells["D22"] = -100000000000L; sheet.Cells["D23"] = -100000000001L; sheet.Cells["D24"] = -1000000000000L; sheet.Cells["D25"] = -1000000000001L; sheet.Cells["D26"] = Cell.LargeNumberNegativeLimit; sheet.Cells["D27"] = Cell.LargeNumberNegativeLimit + 1; sheet.Cells["D28"] = Cell.LargeNumberNegativeLimit - 1; sheet.LargeNumberHandlingMode = LargeNumberHandlingMode.StoreAsText; sheet.Cells["C5"] = "ThinDiagonalCrosshatch"; sheet.Cells["C5"].Fill = new PatternFill { PatternType = PatternType.ThinDiagonalCrosshatch, PatternColor = Color.Yellow, BackgroundColor = Color.Violet }; sheet.Cells["C5"].TextColor = Color.Green; sheet.Cells["C6"] = "ThickDiagonalCrosshatch"; sheet.Cells["C6"].Fill = new PatternFill { PatternType = PatternType.ThickDiagonalCrosshatch, PatternColor = Color.Violet }; sheet.Cells["C6"].TextColor = Color.Green; sheet.Cells["C7"] = "DiagonalCrosshatch"; sheet.Cells["C7"].Fill = new PatternFill { PatternType = PatternType.DiagonalCrosshatch, BackgroundColor = Color.Violet }; sheet.Cells["C7"].TextColor = Color.Green; sheet.Cells["C8"] = "FillSolid"; sheet.Cells["C8"].Fill = new PatternFill { PatternType = PatternType.Solid, PatternColor = Color.Yellow, BackgroundColor = Color.Violet }; sheet.Cells["C8"].TextColor = Color.Green; sheet.Cells["C9"] = "SetFillBgColor"; sheet.Cells["C9"].Fill.BackgroundColor = Color.Navy; sheet.Cells["C9"].TextColor = Color.Green; wb.Add(sheet); // Prime the Cache... var populatedSheet = new Worksheet("Populate"); populatedSheet.Populate(EnumeratePopulateTestData(), cacheTypeColumns: true); // ...and use the cache populatedSheet = new Worksheet("Populate"); populatedSheet.Populate(EnumeratePopulateTestData(), cacheTypeColumns: true); wb.Add(populatedSheet); var frozenTopRowSheet = new Worksheet("Frozen Top Row"); frozenTopRowSheet.Cells[0, 0] = "Header 1"; frozenTopRowSheet.Cells[0, 1] = "Header 2"; frozenTopRowSheet.Cells[0, 2] = "Header 3"; foreach (var i in Enumerable.Range(1, 100)) { frozenTopRowSheet.Cells[i, 0] = "Value 1-" + i; frozenTopRowSheet.Cells[i, 1] = "Value 2-" + i; frozenTopRowSheet.Cells[i, 2] = "Value 3-" + i; } frozenTopRowSheet.FreezeTopRow(); wb.Add(frozenTopRowSheet); var frozenLeftColumnSheet = new Worksheet("Frozen Left Column"); frozenLeftColumnSheet.Cells[0, 0] = "Header 1"; frozenLeftColumnSheet.Cells[1, 0] = "Header 2"; frozenLeftColumnSheet.Cells[2, 0] = "Header 3"; foreach (var i in Enumerable.Range(1, 100)) { frozenLeftColumnSheet.Cells[0, i] = "Value 1-" + i; frozenLeftColumnSheet.Cells[1, i] = "Value 2-" + i; frozenLeftColumnSheet.Cells[2, i] = "Value 3-" + i; } frozenLeftColumnSheet.FreezeLeftColumn(); wb.Add(frozenLeftColumnSheet); var pageBreakSheet = new Worksheet("Page Breaks"); for (var row = 0; row < 20; row++) { for (var col = 0; col < 20; col++) { pageBreakSheet.Cells[row, col] = $"Row {row} /Col {col}"; } } pageBreakSheet.InsertManualPageBreakAfterRow("B1"); pageBreakSheet.InsertManualPageBreakAfterRow(5); pageBreakSheet.InsertManualPageBreakAfterColumn("B8"); pageBreakSheet.InsertManualPageBreakAfterColumn(16); wb.Add(pageBreakSheet); wb.Save("compressed.xlsx", compress: true); wb.Save("uncompressed.xlsx", compress: false); }
protected override Workbook GenerateWorkbook() { var wb = new Workbook(); wb.Title = "Workbook Title"; wb.Author = "The Author"; var sheet = new Worksheet("Test"); sheet.PageSetup.Orientation = Orientation.Landscape; sheet.PageSetup.PrintRepeatRows = 2; sheet.PageSetup.PrintRepeatColumns = 2; sheet.ColumnWidths[0] = 24.6; sheet.Cells["A1"] = "Test"; sheet.Cells["A1"].FontName = "Arial Black"; sheet.Cells[0, 1] = "Another Test"; sheet.Cells[0, 1].Border = CellBorder.Bottom | CellBorder.Right; sheet.Cells[0, 2] = "Bold Red"; sheet.Cells[0, 2].Bold = true; sheet.Cells[0, 2].TextColor = Color.Red; Cell cell = "BIU & Big & Blue"; cell.Bold = true; cell.Underline = true; cell.Italic = true; cell.TextColor = Color.Blue; cell.FontSize = 18; cell.Hyperlink = "https://github.com/mstum/Simplexcel"; sheet.Cells[0, 3] = cell; sheet.ColumnWidths[3] = 40; sheet.Cells[0, 4] = 13; sheet.Cells[0, 5] = 13.58; Cell cell2 = "Orange"; cell2.Bold = true; cell2.Italic = true; cell2.TextColor = Color.Orange; cell2.FontSize = 18; sheet.Cells[0, 2] = cell2; sheet.Cells[0, 6] = "👪"; sheet.Cells[0, 7] = "👨👩👧👦"; var i = 0; foreach (var datum in _data ?? Enumerable.Empty <string>()) { i++; sheet.Cells[i, 0] = datum; } wb.Add(sheet); var sheet2 = new Worksheet("Sheet 2"); sheet2[0, 0] = "Sheet Number 2"; sheet2[0, 0].Bold = true; wb.Add(sheet2); return(wb); }
static void Main(string[] args) { var wb = new Workbook(); wb.Title = "Workbook Title"; wb.Author = "The Author"; var sheet = new Worksheet("Test"); sheet.PageSetup.Orientation = Orientation.Landscape; sheet.PageSetup.PrintRepeatRows = 2; sheet.PageSetup.PrintRepeatColumns = 2; sheet.ColumnWidths[0] = 24.6; sheet.Cells["A1"] = "Test"; sheet.Cells["A1"].FontName = "Arial Black"; sheet.Cells[0, 1] = "Another Test"; sheet.Cells[0, 1].Border = CellBorder.Bottom | CellBorder.Right; sheet.Cells[0, 2] = "Bold Red"; sheet.Cells[0, 2].Bold = true; sheet.Cells[0, 2].TextColor = Color.Red; Cell cell = "BIU & Big & Blue"; cell.Bold = true; cell.Underline = true; cell.Italic = true; cell.TextColor = Color.Blue; cell.FontSize = 18; cell.Hyperlink = "https://github.com/mstum/Simplexcel"; sheet.Cells[0, 3] = cell; sheet.ColumnWidths[3] = 40; sheet.Cells[0, 4] = 13; sheet.Cells[0, 5] = 13.58; for (int i = 1; i < 55; i++) { sheet.Cells[1, i] = Guid.NewGuid().ToString("N"); sheet.Cells[i, 0] = Guid.NewGuid().ToString("N"); } Cell cell2 = "Orange"; cell2.Bold = true; cell2.Italic = true; cell2.TextColor = Color.Orange; cell2.FontSize = 18; sheet.Cells[0, 2] = cell2; sheet.Cells[0, 6] = "👪"; sheet.Cells[0, 7] = "👨👩👧👦"; wb.Add(sheet); var sheet2 = new Worksheet("Sheet 2"); sheet2[0, 0] = "Sheet Number 2"; sheet2[0, 0].Bold = true; wb.Add(sheet2); var populatedSheet = new Worksheet("Populate"); populatedSheet.Populate(EnumeratePopulateTestData()); wb.Add(populatedSheet); wb.Save("compressed.xlsx", compress: true); wb.Save("uncompressed.xlsx", compress: false); }
public static void CreateWeeklyReport(int year, int weekNumber) { try { Log.Debug("Generating Weekly Report."); // Prepare Timesheet Template var sheet = new Worksheet(string.Format("Timesheet", year, weekNumber)); SetTitleCell(sheet, "A2", "Weekly Timesheet"); sheet.ColumnWidths[0] = 30; SetHeadingCell(sheet, "B1", "Year"); SetBodyCell(sheet, "B2", year); SetHeadingCell(sheet, "C1", "Week"); SetBodyCell(sheet, "C2", weekNumber); sheet.ColumnWidths[1] = 10; SetHeadingCell(sheet, "B4", "Morning"); sheet.ColumnWidths[2] = 10; SetHeadingCell(sheet, "C4", "Afternoon"); sheet.ColumnWidths[3] = 10; SetHeadingCell(sheet, "D4", "Evening"); sheet.ColumnWidths[4] = 10; SetHeadingCell(sheet, "E4", "Night"); sheet.ColumnWidths[5] = 15; SetHeadingCell(sheet, "F4", "Day Total"); sheet.ColumnWidths[6] = 15; SetHeadingCell(sheet, "G4", "Day Total Hours"); Log.Debug("Primary headings set."); // Add Data var dateOfDayBeingReportedOn = FirstDateOfWeekISO8601(year, weekNumber); Log.Debug("Identified date for Monday."); SetHeadingCell(sheet, "A5", string.Format("{0} - Monday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 5); Log.Debug("Monday's data generated."); dateOfDayBeingReportedOn = dateOfDayBeingReportedOn.AddDays(1); SetHeadingCell(sheet, "A6", string.Format("{0} - Tuesday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 6); Log.Debug("Tuesday's data generated."); dateOfDayBeingReportedOn = dateOfDayBeingReportedOn.AddDays(1); SetHeadingCell(sheet, "A7", string.Format("{0} - Wednesday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 7); Log.Debug("Wednesday's data generated."); dateOfDayBeingReportedOn = dateOfDayBeingReportedOn.AddDays(1); SetHeadingCell(sheet, "A8", string.Format("{0} - Thursday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 8); Log.Debug("Thursday's data generated."); dateOfDayBeingReportedOn = dateOfDayBeingReportedOn.AddDays(1); SetHeadingCell(sheet, "A9", string.Format("{0} - Friday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 9); Log.Debug("Friday's data generated."); dateOfDayBeingReportedOn = dateOfDayBeingReportedOn.AddDays(1); SetHeadingCell(sheet, "A10", string.Format("{0} - Saturday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 10); Log.Debug("Saturday's data generated."); dateOfDayBeingReportedOn = dateOfDayBeingReportedOn.AddDays(1); SetHeadingCell(sheet, "A11", string.Format("{0} - Sunday", dateOfDayBeingReportedOn.ToString("MMMM dd, yyyy"))); PopulateCellsWithWorkingDayData(sheet, dateOfDayBeingReportedOn, 11); Log.Debug("Sunday's data generated."); SetHeadingCell(sheet, "F13", "Week Total"); SetBodyCellFormula(sheet, "F14", "=SUM(F5:F11)"); SetHeadingCell(sheet, "G13", "Week Total Hours"); SetBodyCellFormula(sheet, "G14", "=SUM(G5:G11)"); Log.Debug("Formulas for caluclating weekly totals added."); var workbook = new Workbook(); workbook.Title = string.Format("{0}-{1}-{2}-alpha", year, weekNumber, Application.ProductVersion); workbook.Author = string.Format("{0}-{1}", Application.ProductName, Application.ProductVersion); Log.Debug("Workbook instantiated with title and author set."); workbook.Add(sheet); Log.Debug("Sheet added to workbook."); #if DEBUG workbook.Save(string.Format(@"{0}\SUT-Timesheet-Test-{1}{2}.xlsx", @"C:\temp", year, weekNumber)); #else workbook.Save(string.Format(@"{0}\SUT-Timesheet-{1}{2}.xlsx", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), year, weekNumber)); #endif } catch (IOException) { var result = MessageBox.Show("The file may be open in another application if the report has been generated before.\n\nControlled Folder Access may be blocking the saving of the report.", "SUT - Report could not be save!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation); if (result == DialogResult.Retry) { CreateWeeklyReport(year, weekNumber); } } catch (Exception exception) { #if DEBUG throw exception; #else Log.Fatal(exception, "Weekly report generation failed."); Application.Exit(); #endif } }
public Task Write(BankDataSheet data) { Worksheet sheet = new Worksheet("Data"); sheet.FreezeTopRow(); sheet.Cells[0, 0] = "Entry ID"; sheet.Cells[0, 1] = "Account"; sheet.ColumnWidths[1] = 12; sheet.Cells[0, 2] = "Date"; sheet.ColumnWidths[2] = 13; sheet.Cells[0, 3] = "Currency"; sheet.Cells[0, 4] = "Amount"; sheet.Cells[0, 5] = "Balance"; sheet.Cells[0, 6] = "PaymentType"; sheet.ColumnWidths[6] = 25; sheet.Cells[0, 7] = "Recipient"; sheet.ColumnWidths[7] = 35; sheet.Cells[0, 8] = "Payer"; sheet.ColumnWidths[8] = 20; sheet.Cells[0, 9] = "Note"; sheet.ColumnWidths[9] = 55; sheet.Cells[0, 10] = "Category"; sheet.ColumnWidths[10] = 25; sheet.Cells[0, 11] = "Subcategory"; sheet.ColumnWidths[11] = 25; sheet.Cells[0, 12] = "Tags"; sheet.Cells[0, 13] = "Full Details"; sheet.ColumnWidths[13] = 70; for (int i = 0; i < sheet.Cells.ColumnCount; i++) { sheet.Cells[0, i].Bold = true; sheet.Cells[0, i].Fill.BackgroundColor = Color.Gray; } for (int rowIndex = 0; rowIndex < data.Entries.Count; rowIndex++) { BankEntry bankEntry = data.Entries[rowIndex]; sheet.Cells[rowIndex + 1, 0] = bankEntry.BankEntryId; if (rowIndex + 1 % 2 == 0) { for (int columnIndex = 0; columnIndex < sheet.Cells.ColumnCount; columnIndex++) { if (columnIndex == 10 || columnIndex == 11) { continue; } sheet.Cells[rowIndex + 1, columnIndex].Fill.BackgroundColor = Color.WhiteSmoke; } } sheet.Cells[rowIndex + 1, 1] = bankEntry.Account; sheet.Cells[rowIndex + 1, 2] = new Cell(CellType.Date, bankEntry.Date, "dd/MM/yyyy"); sheet.Cells[rowIndex + 1, 3] = bankEntry.Currency; sheet.Cells[rowIndex + 1, 4] = bankEntry.Amount; if (bankEntry.Amount < 0) { sheet.Cells[rowIndex + 1, 4].TextColor = Color.Red; sheet.Cells[rowIndex + 1, 4].Bold = true; } else { sheet.Cells[rowIndex + 1, 4].TextColor = Color.Green; sheet.Cells[rowIndex + 1, 4].Bold = true; } sheet.Cells[rowIndex + 1, 5] = bankEntry.Balance; sheet.Cells[rowIndex + 1, 6] = bankEntry.PaymentType; sheet.Cells[rowIndex + 1, 7] = bankEntry.Recipient; sheet.Cells[rowIndex + 1, 7].Border = CellBorder.Right | CellBorder.Left; sheet.Cells[rowIndex + 1, 7].Bold = true; sheet.Cells[rowIndex + 1, 8] = bankEntry.Payer; sheet.Cells[rowIndex + 1, 9] = bankEntry.Note; sheet.Cells[rowIndex + 1, 10] = bankEntry.Category; sheet.Cells[rowIndex + 1, 10].Fill.BackgroundColor = Color.MediumSeaGreen; sheet.Cells[rowIndex + 1, 11] = bankEntry.Subcategory; sheet.Cells[rowIndex + 1, 11].Fill.BackgroundColor = Color.DarkSeaGreen; sheet.Cells[rowIndex + 1, 12] = string.Join(";", bankEntry.Tags); sheet.Cells[rowIndex + 1, 13] = bankEntry.FullDetails; } Workbook workbook = new Workbook(); workbook.Add(sheet); workbook.Save(this.targetFilePath); return(Task.CompletedTask); }