private async void ExportXLSX() { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using var p = new ExcelPackage(); // content var ws = p.Workbook.Worksheets.Add(_("Overview")); ws.Cells["A1"].Value = _("Color Usage Overview"); ws.Cells["A1"].Style.Font.Size = 15; var HeaderRow = ProjectColorList.GetDepth(DominoAssembly); // var offset = HeaderRow + 4; ws.Cells[offset - 1, 2].Value = _("Color"); ws.Cells[offset - 1, 3].Value = GetParticularString("Total color count available", "Available"); ColorListWithoutDeleted = ColorList.Where(x => x.GetColorState() != DominoColorState.Deleted).ToList(); var TotalColors = ColorListWithoutDeleted.Count; for (int i = 0; i < TotalColors; i++) { ws.Cells[offset + i, 1].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; ws.Cells[offset + i, 1].Style.Fill.BackgroundColor.SetColor(ColorListWithoutDeleted[i].DominoColor.mediaColor.ToSD()); ws.Cells[offset + i, 2].Value = ColorListWithoutDeleted[i].DominoColor.name; ws.Cells[offset + i, 3].Value = ColorListWithoutDeleted[i].DominoColor.count; if (ColorListWithoutDeleted[i].GetColorState() == DominoColorState.Inactive) { // mark deleted colors gray ws.Cells[offset + i, 1, offset + i, 3].Style.Font.Color.SetColor(255, 100, 100, 100); } } ws.Cells[offset, 3].Value = ""; // Count of empty domino var length = ExportAssemblyToExcel(ws, DominoAssembly, 0, 0, 0, HeaderRow); int index = length.Item1; // add lines ws.Cells[3, 3, 4 + TotalColors + HeaderRow, 3 + index].Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; ws.Cells[2, 1, 3 + TotalColors + HeaderRow, 3 + index].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; ws.Cells[3 + HeaderRow, 1, 3 + HeaderRow, 3 + index].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick; ws.Cells[3 + HeaderRow + TotalColors, 1, 3 + HeaderRow + TotalColors, 3 + index].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick; ws.Calculate(); // auto fit unfortunately doesn't work for merged cells (project headers) //ws.Cells.AutoFitColumns(); SaveFileDialog dlg = new SaveFileDialog { InitialFileName = GetParticularString("Default filename for color list", "ColorList"), Filters = new List <FileDialogFilter>() { new FileDialogFilter() { Extensions = new List <string> { "xlsx" }, Name = _("Excel files") }, new FileDialogFilter() { Extensions = new List <string> { "*" }, Name = _("All files") } }, Directory = DialogExtensions.GetCurrentProjectPath() }; var result = await dlg.ShowAsyncWithParent <MainWindow>(); if (!string.IsNullOrEmpty(result)) { try { p.SaveAs(new FileInfo(result)); var process = new Process(); process.StartInfo = new ProcessStartInfo(result) { UseShellExecute = true }; process.Start(); } catch (Exception ex) { await Errorhandler.RaiseMessage(string.Format(_("Save failed: {0}"), ex.Message), _("Error"), Errorhandler.MessageType.Error); } } }