private void FormatRevenueByPac(Worksheet revenueByPacDestSheet) { if (revenueByPacDestSheet.Cells[1, 4].Text == "DataSource") { ExcelUtilies.DeleteColumns(revenueByPacDestSheet, "D", "D"); } if (revenueByPacDestSheet.Cells[1, 1].Text == "YearMonth") { ExcelUtilies.DeleteColumns(revenueByPacDestSheet, "A", "A"); } if (revenueByPacDestSheet.Cells[1, 2].Text == "CityName") { revenueByPacDestSheet.Range["B1"].Value = ""; } if (revenueByPacDestSheet.Cells[1, 1].Text == "ProductCategory") { revenueByPacDestSheet.Range["A1"].Value = "MTD"; int endRow = 2; string label = revenueByPacDestSheet.Cells[endRow, 1].Text; while (!string.IsNullOrWhiteSpace(label)) { endRow++; label = revenueByPacDestSheet.Cells[endRow, 1].Text; } endRow--; Range range = revenueByPacDestSheet.Range["A2", "A" + endRow]; this.MergeCells(range, "Mini Center"); } revenueByPacDestSheet.Range["A1", "H12"].Interior.ColorIndex = 0; //revenueByPacDestSheet.Range["A1", "F1"].Interior.Color = this.ColumnColor; revenueByPacDestSheet.Range["A1", "F1"].Font.Bold = true; ExcelUtilies.InsertRow(revenueByPacDestSheet, "A1"); ExcelUtilies.InsertRow(revenueByPacDestSheet, "A1"); ExcelUtilies.InsertRow(revenueByPacDestSheet, "A1"); revenueByPacDestSheet.Range["A1"].Value = "Currency"; revenueByPacDestSheet.Range["A2"].Value = "RMB"; revenueByPacDestSheet.Range["A2"].Font.Bold = true; revenueByPacDestSheet.Range["A2"].Interior.Color = this.ColumnColor; this.MergeCells(revenueByPacDestSheet.Range["A3", "C3"], "Mini Center Rev not include Mini TS and B2B"); }
private void FormatSummary(Excel.Worksheet summaryDestSheet) { summaryDestSheet.Range["A1", "AZ100"].Interior.ColorIndex = 0; this.MergeCellsForSummary(summaryDestSheet); ExcelUtilies.InsertRow(summaryDestSheet, "A1"); ExcelUtilies.InsertRow(summaryDestSheet, "A1"); ExcelUtilies.InsertRow(summaryDestSheet, "A1"); summaryDestSheet.Range["A4", "AX4"].Font.Bold = true; summaryDestSheet.Range["A3", "AX3"].Merge(); summaryDestSheet.Range["A3", "AX3"].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; summaryDestSheet.Range["A3", "AX3"].VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; summaryDestSheet.Range["A3", "AX3"].Value = "Funnel Performance"; summaryDestSheet.Range["A3", "AX3"].Font.Color = Color.White; summaryDestSheet.Range["A3", "AX3"].Font.Bold = true; summaryDestSheet.Range["A3", "AX3"].Interior.Color = Color.DarkBlue; summaryDestSheet.Range["A1", "C1"].Merge(); summaryDestSheet.Range["A1", "C1"].Value = "Center Month To Date Summary as"; summaryDestSheet.Range["A1", "K1"].Font.Bold = true; summaryDestSheet.Range["F1", "H1"].Merge(); summaryDestSheet.Range["F1", "H1"].Value = "Total days of this month"; summaryDestSheet.Range["D1"].Value = DateTime.Today.ToString("yyyy/MM/dd"); summaryDestSheet.Range["D1"].Font.Color = Color.Red; summaryDestSheet.Range["D1"].ColumnWidth = 10; DateTime date = DateTime.Today; summaryDestSheet.Range["I1"].Value = DateTime.DaysInMonth(date.Year, date.Month); summaryDestSheet.Range["I1"].Font.Color = Color.Red; summaryDestSheet.Range["K1", "L1"].Merge(); summaryDestSheet.Range["K1", "L1"].Value = "Time Ratio"; summaryDestSheet.Range["M1", "N1"].Merge(); summaryDestSheet.Range["M1", "N1"].Value = string.Format("{0:N2}%", ((float)date.Day / (float)DateTime.DaysInMonth(date.Year, date.Month)) * 100); summaryDestSheet.Range["M1", "N1"].Font.Color = Color.Red; ExcelUtilies.FreezePanes(summaryDestSheet, 2, 4); }
private void FormatSummary(Excel.Worksheet summaryDestSheet) { summaryDestSheet.Range["A1", "T100"].Interior.ColorIndex = 0; this.MergeCellsForSummary(summaryDestSheet); ExcelUtilies.InsertRow(summaryDestSheet, "A1"); ExcelUtilies.InsertRow(summaryDestSheet, "A1"); ExcelUtilies.InsertRow(summaryDestSheet, "A1"); summaryDestSheet.Range["A4", "T4"].Font.Bold = true; summaryDestSheet.Range["A3", "T3"].Merge(); summaryDestSheet.Range["A3", "T3"].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; summaryDestSheet.Range["A3", "T3"].VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; summaryDestSheet.Range["A3", "T3"].Value = "Funnel Performance"; summaryDestSheet.Range["A3", "T3"].Font.Color = Color.White; summaryDestSheet.Range["A3", "T3"].Font.Bold = true; summaryDestSheet.Range["A3", "T3"].Interior.Color = Color.DarkBlue; summaryDestSheet.Range["A1", "C1"].Merge(); summaryDestSheet.Range["A1", "C1"].Value = "Mini Center Month To Date Summary as"; summaryDestSheet.Range["A1", "H1"].Font.Bold = true; summaryDestSheet.Range["F1", "G1"].Merge(); summaryDestSheet.Range["F1", "G1"].Value = "Total days of this month"; summaryDestSheet.Range["D1"].Value = summaryDestSheet.Cells[5, 1].Text; summaryDestSheet.Range["D1"].Font.Color = Color.Red; DateTime date; if (DateTime.TryParse(summaryDestSheet.Cells[1, 4].Text, out date)) { summaryDestSheet.Range["H1"].Value = DateTime.DaysInMonth(date.Year, date.Month); } else { summaryDestSheet.Range["H1"].Value = DateTime.DaysInMonth(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month); } summaryDestSheet.Range["H1"].Font.Color = Color.Red; ExcelUtilies.FreezePanes(summaryDestSheet, 3, 4); }
private void FormatFinalReportSheet(Excel.Worksheet sheet) { //Insert a row to set the title ExcelUtilies.InsertRow(sheet, "A1"); sheet.Cells[1, 1] = sheet.Name; //insert two rows, total excel start with Row 3 ExcelUtilies.InsertRow(sheet, "A1"); this.SetBackgroundColor(sheet); this.CalculateRententionRate(sheet); string endColumn = ExcelUtilies.ExcelColumnIndexToName(ExcelUtilies.ExcelColumnNameToIndex(FunnelMonthlyReportParameters.MonthEnd)); string startColumn = this.GetCurrentMonthExcelColumn(); if (ExcelUtilies.ExcelColumnNameToIndex(startColumn) <= ExcelUtilies.ExcelColumnNameToIndex(endColumn)) { ExcelUtilies.DeleteColumns(sheet, startColumn, endColumn); } //for Europe remove the values of Spot Rate and KFR Rate if (sheet.Name == "Europe" || sheet.Name == "Mexico+US") { int endMonthColumn = ExcelUtilies.ExcelColumnNameToIndex(this.GetCurrentMonthExcelColumn()); for (int i = 2; i < endMonthColumn; i++) { //Spot Rate sheet.Cells[4, i] = string.Empty; //KFR Rate sheet.Cells[5, i] = string.Empty; } } this.FormatCells(sheet); this.FreezePanes(sheet); }
private void FormatMiniTS(Excel.Worksheet copyDestSheet, string header) { copyDestSheet.Range["A1", "GI500"].Interior.ColorIndex = 0; int endColum = this.GetColumnHasValueEndIndex(copyDestSheet, 1, 2); this.MergeHeader(copyDestSheet, 1, 2, endColum - 1, "Mini TS " + header); Range range = copyDestSheet.Range["A1", copyDestSheet.Cells[2, endColum - 1]]; range.Borders.Weight = 2; range.Borders.Color = Color.Black; //color column A copyDestSheet.Range["A1"].EntireColumn.Interior.ColorIndex = 0; int begin = this.GetWeeks(CurrentDate) + 3; int end = begin + this.GetDays(CurrentDate); ExcelUtilies.DeleteRow(copyDestSheet, "A" + begin); ExcelUtilies.DeleteRow(copyDestSheet, "A" + begin); copyDestSheet.Range["A" + begin, "A" + end].Interior.Color = this.ColumnColor; this.DeleteEmptyRows(copyDestSheet); //Set currency label ExcelUtilies.InsertRow(copyDestSheet, "A1"); ExcelUtilies.InsertRow(copyDestSheet, "A1"); ExcelUtilies.InsertRow(copyDestSheet, "A1"); copyDestSheet.Range["A1"].Value = "Currency"; copyDestSheet.Range["A2"].Value = "RMB"; copyDestSheet.Range["A2"].Font.Bold = true; copyDestSheet.Range["A2"].Interior.Color = this.ColumnColor; ExcelUtilies.FreezePanes(copyDestSheet, 1, 5); }
private void FormatDetail(Excel.Worksheet copyDestSheet, string header) { copyDestSheet.Range["A1", "GI500"].Interior.ColorIndex = 0; this.FormatDetailHeaders(copyDestSheet, header); //Range range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Online_BeginCell, FunnelCNMiniMergeParameters.Online_EndCell]; //this.MergeCells(range, header + " Online"); //range = copyDestSheet.Range[FunnelCNMiniMergeParameters.IB_BeginCell, FunnelCNMiniMergeParameters.IB_EndCell]; //this.MergeCells(range, header + " IB"); //range = copyDestSheet.Range[FunnelCNMiniMergeParameters.WI_BeginCell, FunnelCNMiniMergeParameters.WI_EndCell]; //this.MergeCells(range, header + " WI"); //range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Offline_BeginCell, FunnelCNMiniMergeParameters.Offline_EndCell]; //this.MergeCells(range, header + " Offline"); //if (copyDestSheet.Name == "NJ2 Details") //{ // //No B2B and Others // //range = copyDestSheet.Range[FunnelCNMiniMergeParameters.B2B_BeginCell, FunnelCNMiniMergeParameters.B2B_EndCell]; // //this.MergeCells(range, header + " B2B"); // //range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Others_BeginCell, FunnelCNMiniMergeParameters.Others_EndCell]; // //this.MergeCells(range, header + " Others"); // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.B2B_BeginCell, FunnelCNMiniMergeParameters.B2B_EndCell]; // this.MergeCells(range, header + " Total"); // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Online_BeginCell, FunnelCNMiniMergeParameters.B2B_EndCell.Replace("1", "2")]; // range.Interior.Color = this.HeaderColor; // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.B2B_BeginCell, FunnelCNMiniMergeParameters.B2B_EndCell.Replace("1", "2")]; // range.Interior.Color = Color.Gray; // //merge cells for special weekly // int startColumn = ExcelUtilies.ExcelColumnNameToIndex("CK"); // int endColum = this.MergeHeader(copyDestSheet, 1, startColumn, header); // range = copyDestSheet.Range["A1", copyDestSheet.Cells[2, endColum - 2]]; // range.Borders.Weight = 2; // range.Borders.Color = Color.Black; //} //else //{ // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.B2B_BeginCell, FunnelCNMiniMergeParameters.B2B_EndCell]; // this.MergeCells(range, header + " B2B"); // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Others_BeginCell, FunnelCNMiniMergeParameters.Others_EndCell]; // this.MergeCells(range, header + " Others"); // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Online_BeginCell, FunnelCNMiniMergeParameters.Total_EndCell.Replace("1", "2")]; // range.Interior.Color = this.HeaderColor; // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Total_BeginCell, FunnelCNMiniMergeParameters.Total_EndCell]; // this.MergeCells(range, header + " Total"); // range = copyDestSheet.Range[FunnelCNMiniMergeParameters.Total_BeginCell, FunnelCNMiniMergeParameters.Total_EndCell.Replace("1", "2")]; // range.Interior.Color = Color.Gray; // //merge cells for special weekly // int startColumn = ExcelUtilies.ExcelColumnNameToIndex("DS"); // int endColum = this.MergeHeader(copyDestSheet, 1, startColumn, header); // range = copyDestSheet.Range["A1", copyDestSheet.Cells[2, endColum - 2]]; // range.Borders.Weight = 2; // range.Borders.Color = Color.Black; //} //color column A copyDestSheet.Range["A1"].EntireColumn.Interior.ColorIndex = 0; int begin = this.GetWeeks(CurrentDate) + 3; int end = begin + this.GetDays(CurrentDate); //delete daily headers ExcelUtilies.DeleteRow(copyDestSheet, "A" + begin); ExcelUtilies.DeleteRow(copyDestSheet, "A" + begin); copyDestSheet.Range["A" + begin, "A" + end].Interior.Color = this.ColumnColor; this.DeleteEmptyRows(copyDestSheet); //Set currency label ExcelUtilies.InsertRow(copyDestSheet, "A1"); ExcelUtilies.InsertRow(copyDestSheet, "A1"); ExcelUtilies.InsertRow(copyDestSheet, "A1"); copyDestSheet.Range["A1"].Value = "Currency"; copyDestSheet.Range["A2"].Value = "RMB"; copyDestSheet.Range["A2"].Font.Bold = true; copyDestSheet.Range["A2"].Interior.Color = this.ColumnColor; ExcelUtilies.FreezePanes(copyDestSheet, 1, 5); }
private Excel.Workbook MergedOutputFiles(Excel.Application excel, Dictionary <string, ReportContext> MergedFiles) { Dictionary <string, string> thisMonthReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "ThisMonth"); Dictionary <string, string> monthReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "1011Month"); Dictionary <string, string> monthDiffReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "MonthDiff"); Dictionary <string, string> actualReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "Actuals"); Dictionary <string, string> KFRxReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "KFRx"); Dictionary <string, string> DiffReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "Diff"); Dictionary <string, string> PriorYearReports = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "PriorYear"); Dictionary <string, string> PriorYearDiffReport = FunnelReportHelper.GetOutputMergedFilesByCategory(MergedFiles, "PriorYearDiff"); if (thisMonthReports.Count == 0) { return(null); } Excel.Workbook tempWorkbook = null; try { this.Logger.Message("Create tempWorkbook."); tempWorkbook = excel.Workbooks.Add(Missing.Value); //this.AddCategoryOutputSheet(tempWorkbook); this.Logger.Message("Create Output Sheets."); Excel.Worksheet outputTotalSheet = tempWorkbook.Sheets.Add(); outputTotalSheet.Name = OutputTotal; Excel.Worksheet outputJapanSheet = tempWorkbook.Sheets.Add(); outputJapanSheet.Name = OutputJPKR; Excel.Worksheet outputBrazilSheet = tempWorkbook.Sheets.Add(); outputBrazilSheet.Name = OutputBrazil; Excel.Worksheet outputEuropeSheet = tempWorkbook.Sheets.Add(); outputEuropeSheet.Name = OutputEurope; Excel.Worksheet outputMXUSSheet = tempWorkbook.Sheets.Add(); outputMXUSSheet.Name = OutputMXUS; Excel.Worksheet outputOthersSheet = tempWorkbook.Sheets.Add(); outputOthersSheet.Name = OutputOthers; //create a new work sheet Excel.Worksheet tempWorkSheet = tempWorkbook.Worksheets[1] as Excel.Worksheet; this.Logger.Message("Copy to tempwork."); foreach (var item in actualReports.Keys) { thisMonthBook = excel.Workbooks.Open(thisMonthReports[item]); Excel.Worksheet thisMonthSheet = thisMonthBook.Worksheets[1]; thisMonthSheet.Name = item; //copy month report to dest //Column B - M thisMonthSheet.Copy(Missing.Value, tempWorkSheet); Excel.Worksheet copyDestSheet = tempWorkbook.Worksheets[item]; if (string.IsNullOrWhiteSpace(copyDestSheet.Cells[1, 1].Text)) { ExcelUtilies.DeleteRow(copyDestSheet, "A1"); } //month if (monthReports.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputMonth, monthReports[item], 1); } //monthDiff if (monthDiffReports.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputMonthDiff, monthDiffReports[item], 2); } //Actuals if (actualReports.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputActuals, actualReports[item], 3); } //KFR1 if (KFRxReports.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputKFR1, KFRxReports[item], 4); } //Diff if (DiffReports.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputDiff, DiffReports[item], 5); } //PriorYear if (PriorYearReports.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputPriorYear, PriorYearReports[item], 6); } //PriorYearDiff if (PriorYearDiffReport.ContainsKey(item)) { this.AppendReport(tempWorkbook, copyDestSheet, item, FunnelMonthlyReportParameters.OutputPriorYearDiff, PriorYearDiffReport[item], 7); } if (!string.IsNullOrWhiteSpace(copyDestSheet.Cells[1, 1].Text)) { ExcelUtilies.InsertRow(copyDestSheet, "A1"); } this.SetHeaderTitle(copyDestSheet); this.CloseOutputSourceReportsExcel(); #region Category output Logger.Message("Category output " + item); this.FormatOutputCells(copyDestSheet); copyDestSheet.Activate(); if (item == "Japan") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputJapanSheet, "A3"); outputJapanSheet.Cells[2, 1] = item; } else if (item == "Korea") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputJapanSheet, "A21"); outputJapanSheet.Cells[20, 1] = item; } else if (item == "Total") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputTotalSheet, "A3"); outputTotalSheet.Cells[2, 1] = item; } else if (item == "Brazil") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputBrazilSheet, "A3"); outputBrazilSheet.Cells[2, 1] = item; } else if (item == "Europe") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A3"); outputEuropeSheet.Cells[2, 1] = item; } else if (item == "Spain") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A19"); outputEuropeSheet.Cells[18, 1] = item; } else if (item == "MEAST") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A37"); outputEuropeSheet.Cells[36, 1] = item; } else if (item == "ROE") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A55"); outputEuropeSheet.Cells[54, 1] = item; } else if (item == "Italy") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A73"); outputEuropeSheet.Cells[72, 1] = item; } else if (item == "Germany") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A91"); outputEuropeSheet.Cells[90, 1] = item; } else if (item == "France") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputEuropeSheet, "A109"); outputEuropeSheet.Cells[108, 1] = item; } else if (item == "Mexico+US+ROLA") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputMXUSSheet, "A3"); outputMXUSSheet.Cells[2, 1] = item; } else if (item == "US") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputMXUSSheet, "A19"); outputMXUSSheet.Cells[18, 1] = item; } else if (item == "Mexico") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputMXUSSheet, "A37"); outputMXUSSheet.Cells[36, 1] = item; } else if (item == "ROLA") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputMXUSSheet, "A55"); outputMXUSSheet.Cells[54, 1] = item; } else if (item == "ROA") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputOthersSheet, "A3"); outputOthersSheet.Cells[2, 1] = item; } else if (item == "ROW") { ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputOthersSheet, "A19"); outputOthersSheet.Cells[18, 1] = item; } //else if (item == "Thailand") //{ // ExcelUtilies.CopyRange(copyDestSheet, "A1", "I13", outputOthersSheet, "A37"); // outputOthersSheet.Cells[36, 1] = item; //} #endregion } this.FormatOutputColumnWidth(outputJapanSheet); this.FormatOutputColumnWidth(outputTotalSheet); this.FormatOutputColumnWidth(outputMXUSSheet); this.FormatOutputColumnWidth(outputOthersSheet); this.FormatOutputColumnWidth(outputBrazilSheet); this.FormatOutputColumnWidth(outputEuropeSheet); } catch (Exception ex) { this.CloseOutputSourceReportsExcel(); throw; } return(tempWorkbook); }
private void InsertBlankRow(Excel.Worksheet sheet, string cell) { ExcelUtilies.InsertRow(sheet, cell); sheet.Range[cell].EntireRow.Interior.ColorIndex = -1; sheet.Range[cell].EntireRow.RowHeight = sheet.Range[cell].EntireRow.RowHeight / 2; }