private static void ExportHDPsToExcel(DataTable dt_Handicaps1, DataTable dt_Handicaps, DataTable dt_Handicaps2, DataTable dt_Odds, DataTable dt_OUs1, DataTable dt_OUs, DataTable dt_OUs2, DataTable dt_Avg, string League, string strFileName, bool flagOpen) { try { int i = 2; string strPathTemp = Application.StartupPath + @"\Charts"; string strPath = strPathTemp + @"\" + League; if (!System.IO.Directory.Exists(strPath)) { System.IO.Directory.CreateDirectory(strPath); } string strTemplate = strPathTemp + @"\" + "OddsGraph.xlsx"; clsExcelHelper xlsHelper = new clsExcelHelper(); // Open template chart xlsHelper.OpenExcelAppWithFile(strTemplate, false); // Clear old data xlsHelper.WriteBlock("A2", 6, 30, String.Empty); xlsHelper.WriteBlock("A10", 6, 30, String.Empty); xlsHelper.WriteBlock("A18", 6, 30, String.Empty); xlsHelper.WriteBlock("B26", 6, 19, String.Empty); xlsHelper.WriteBlock("A34", 6, 30, String.Empty); xlsHelper.WriteBlock("A42", 6, 30, String.Empty); xlsHelper.WriteBlock("A50", 6, 30, String.Empty); xlsHelper.WriteBlock("C58", 6, 14, String.Empty); //DataRow[] dr_Handicaps = dt_Handicaps.Select("[Bookmaker] <> 'Convergence'"); // Write HDP foreach (DataRow dr_hdp1 in dt_Handicaps1.Rows) { for (int j = 1; j < 31; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_hdp1[j - 1]); } i++; } i = 10; foreach (DataRow dr_hdp in dt_Handicaps.Rows) { for (int j = 1; j < 31; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_hdp[j - 1]); } i++; } i = 18; foreach (DataRow dr_hdp2 in dt_Handicaps2.Rows) { for (int j = 1; j < 31; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_hdp2[j - 1]); } i++; } // Write odds i = 26; foreach (DataRow dr_odd in dt_Odds.Rows) { for (int j = 2; j < 21; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_odd[j - 2]); } i++; } // Write OUs i = 34; foreach (DataRow dr_ou1 in dt_OUs1.Rows) { for (int j = 1; j < 31; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_ou1[j - 1]); } i++; } i = 42; foreach (DataRow dr_ou in dt_OUs.Rows) { for (int j = 1; j < 31; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_ou[j - 1]); } i++; } i = 50; foreach (DataRow dr_ou2 in dt_OUs2.Rows) { for (int j = 1; j < 31; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_ou2[j - 1]); } i++; } i = 58; foreach (DataRow dr_Avg in dt_Avg.Rows) { for (int j = 0; j < 14; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j + 2) + i, dr_Avg[j]); } i++; } //Save file xlsHelper.SaveToFile(strPath + @"\" + strFileName); xlsHelper.CloseExcel(); if (flagOpen) { // Open chart to preview Process.Start(strPath + @"\" + strFileName); } } catch (Exception ex) { logger.Debug(ex.ToString()); throw ex; } }
private void ExportOddsToExcel(DataTable dt_Odds, string League, string strFileName, bool flagOpen) { try { int i = 2; string strPathTemp = Application.StartupPath + @"\Charts"; string strPath = strPathTemp + @"\" + League; if (!System.IO.Directory.Exists(strPath)) { System.IO.Directory.CreateDirectory(strPath); } string strTemplate = strPathTemp + @"\" + "Tips.xlsx"; clsExcelHelper xlsHelper = new clsExcelHelper(); // Open template chart xlsHelper.OpenExcelAppWithFile(strTemplate, false); xlsHelper.WriteBlock("B2", 6, 19, String.Empty); // Write odds foreach (DataRow dr_odd in dt_Odds.Rows) { for (int j = 2; j < 21; j++) { xlsHelper.WriteCell(CalculateExcelColumnIndex_Alphabet(j - 1) + i, dr_odd[j - 2]); } i++; } //Save file xlsHelper.SaveToFile(strPath + @"\" + strFileName); xlsHelper.CloseExcel(); if (flagOpen) { // Open chart to preview Process.Start(strPath + @"\" + strFileName); } } catch (Exception ex) { logger.Debug(ex.ToString()); throw ex; } }