private void ReadExcelTransactions() { string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GetFromConfig("TransactionMapFilePath")); log.Log(string.Format("Opening {0} Excel file", file)); try { if (File.Exists(file)) { Application xlApp = new Application(); Workbook xlWorkbook = xlApp.Workbooks.Open(file); //CreateTranUnitMappedEntities(xlWorkbook); xlWorkbook.Close(); xlApp.Quit(); } } catch (Exception e) { log.Log(string.Format("Error processing {0} Excel file: {1}", file, e.Message)); } }
/// <summary> /// Function to Fill the excel work sheet. /// </summary> /// <param name="application">Instance of Excel application.</param> private void FillExcelWorkSheet(Application application) { var workbook = application.Workbooks.Add(Missing.Value); var worksheet = workbook.ActiveSheet as Worksheet; if (worksheet != null) { worksheet._DisplayRightToLeft = 0; int rowNumber = 7; ApplyStyleToExcel(worksheet); this.WriteReportHeader(worksheet); WriteColumnHeader(worksheet); this.personHistory.Iterate(e => { WriteDataIntoExcelSheet(worksheet, e, rowNumber); ++rowNumber; }); var column = worksheet.get_Range(StartColumRange, EndColumRange); if (column != null) { column.EntireColumn.AutoFit(); } } }
private void ReadExcelTriggers(string filePath) { log.Log(string.Format("Opening {0} Excel file", filePath)); try { if (File.Exists(filePath)) { Application xlApp = new Application(); Workbook xlWorkbook = xlApp.Workbooks.Open(filePath); ExtractExcelTriggers(xlWorkbook); xlWorkbook.Close(); xlApp.Quit(); } } catch (Exception e) { log.Log(string.Format("Error processing {0} Excel file: {1}", filePath, e.Message)); } }
/// <summary> /// Function to Manage the excel work sheet. /// </summary> private void ManageExcelWorkSheet() { var application = new Application(); this.FillExcelWorkSheet(application); application.Visible = true; }
/// <summary> /// Function to Fill the excel work sheet. /// </summary> /// <param name="application">Instance of Excel application.</param> private void FillExcelWorkSheet(Application application) { ////CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; ////Thread.CurrentThread.CurrentCulture = new CultureInfo(CultureInfo); var workbook = application.Workbooks.Add(Missing.Value); var worksheet = workbook.ActiveSheet as Worksheet; if (worksheet != null) { worksheet._DisplayRightToLeft = 0; int rowNumber = 6; ApplyStyleToExcel(worksheet); this.WriteReportHeader(worksheet); WriteColumnHeader(worksheet); this.gangwayHistory.Iterate(e => { WriteDataIntoExcelSheet(worksheet, e, rowNumber); ++rowNumber; }); var column = worksheet.get_Range(StartColumRange, EndColumRange); if (column != null) { column.EntireColumn.AutoFit(); } } ////Thread.CurrentThread.CurrentCulture = currentCulture; }