public Task ExportResultsToExcelAsync(IndividualSimulation individualSimulation, string fileName, bool launchExcel = true) { var exportOption = new DataColumnExportOptions { ColumnNameRetriever = x => _quantityDisplayPathMapper.DisplayPathAsStringFor(individualSimulation, x) }; return(_dataRepositoryTask.ExportToExcelAsync(individualSimulation.DataRepository, fileName, launchExcel, exportOption)); }
public Task ExportToCsvAsync(ISimulation simulation, DataRepository results, string fileName) { var options = new DataColumnExportOptions { ColumnNameRetriever = x => _quantityDisplayPathMapper.DisplayPathAsStringFor(simulation, x), UseDisplayUnit = false }; return(_dataRepositoryTask.ExportToCsvAsync(results, fileName, options)); }
protected override void Context() { base.Context(); A.CallTo(() => _dataRepositoryTask.ExportToCsvAsync(A <IEnumerable <DataColumn> > ._, _fileName, A <DataColumnExportOptions> ._)) .Invokes(x => _exportOptions = x.GetArgument <DataColumnExportOptions>(2)); _dataColumn = DomainHelperForSpecs.ObservedData().FirstDataColumn(); _dataColumn.Name = "TOTO"; A.CallTo(() => _quantityDisplayPathMapper.DisplayPathAsStringFor(_simulation, _dataColumn, false)).Returns("NEW NAME"); }
public IReadOnlyList <DataTable> ToDataTable( IEnumerable <DataColumn> dataColumns, DataColumnExportOptions exportOptions = null ) { var options = exportOptions ?? new DataColumnExportOptions(); var allColumns = allColumnsWithRelatedColumnsFrom(dataColumns); var cacheName = retrieveUniqueNamesForTables(allColumns); var valueFormatter = valueFormatterFor(options.FormatOutput); var columnType = options.ForceColumnTypeAsObject ? typeof(object) : options.FormatOutput ? typeof(string) : typeof(float); var columnNameRetrieverFunc = options.ColumnNameRetriever; var dimensionRetrieverFunc = options.DimensionRetriever; var useDisplayUnit = options.UseDisplayUnit; return(cacheName.KeyValues.Select(keyValuePair => createTableFor(keyValuePair.Value, keyValuePair.Key, allColumns, columnNameRetrieverFunc, dimensionRetrieverFunc, useDisplayUnit, columnType, valueFormatter)).ToList()); }
public IEnumerable <DataTable> ExportToDataTable(IEnumerable <DataColumn> dataColumns, GlobalPKAnalysis globalPKAnalysis, DataTable dataTable, IEnumerable <Simulation> simulations) { var allDataTables = new List <DataTable>(); var allSimulations = simulations.ToList(); if (allSimulations.Any()) { var exportOptions = new DataColumnExportOptions { ColumnNameRetriever = x => _quantityDisplayPathMapper.DisplayPathAsStringFor(simulationForColumn(x, allSimulations), x), DimensionRetriever = _dimensionFactory.MergedDimensionFor }; allDataTables.AddRange(_dataRepositoryTask.ToDataTable(dataColumns, exportOptions)); } allDataTables.Add(_globalPKAnalysisToDataTableMapper.MapFrom(globalPKAnalysis)); allDataTables.Add(dataTable); return(allDataTables); }
public void ExportToExcel(CurveChart chart) { if (chart == null) { return; } var visibleCurves = chart.Curves.Where(x => x.Visible).ToList(); if (!visibleCurves.Any()) { return; } var fileName = _dialogCreator.AskForFileToSave(Captions.ExportChartToExcel, Constants.Filter.EXCEL_SAVE_FILE_FILTER, Constants.DirectoryKey.REPORT, chart.Name); if (string.IsNullOrEmpty(fileName)) { return; } // Goal is to use the curve name if it's defined instead of the data column name var dataColumnCache = new Cache <DataColumn, Curve>(onMissingKey: x => null); visibleCurves.Each(curve => dataColumnCache[curve.yData] = curve); //Base grid are added by default to the export unless the data represents an amount vs obs data. In that case, the base grid might be another column var otherColumnsToExport = visibleCurves.Select(x => x.xData).Where(x => !x.IsBaseGrid()); var exportOptions = new DataColumnExportOptions { ColumnNameRetriever = col => dataColumnCache[col]?.Name ?? col.Name, DimensionRetriever = _dimensionFactory.MergedDimensionFor }; _dataRepositoryTask.ExportToExcel(dataColumnCache.Keys.Union(otherColumnsToExport), fileName, exportOptions: exportOptions); }
public Task ExportToCsvAsync(IEnumerable <DataColumn> dataColumns, string fileName, DataColumnExportOptions exportOptions = null) { return(Task.Run(() => { var dataTables = ToDataTable(dataColumns, exportOptions); if (dataTables.Count == 1) { dataTables[0].ExportToCSV(fileName); } else if (dataTables.Count > 1) { throw new ArgumentException(Error.ExportToCsvNotSupportedForDifferentBaseGrid); } })); }
public Task ExportToExcelAsync(IEnumerable <DataColumn> dataColumns, string fileName, bool launchExcel = true, DataColumnExportOptions exportOptions = null) => ExportToExcelAsync(ToDataTable(dataColumns, exportOptions), fileName, launchExcel);