Exemple #1
0
        public void ExportToExcel(IEnumerable <DataColumn> dataColumns, GlobalPKAnalysis globalPKAnalysis, DataTable pkAnalysisDataTable, IEnumerable <Simulation> simulations)
        {
            var    allSimulations  = simulations.ToList();
            string defaultFileName = allSimulations.Count == 1 ? allSimulations[0].Name : string.Empty;
            var    fileName        = _dialogCreator.AskForFileToSave(PKSimConstants.UI.ExportPKAnalysesToExcelTitle, Constants.Filter.EXCEL_SAVE_FILE_FILTER, Constants.DirectoryKey.REPORT, defaultFileName);

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            var allDataTables = ExportToDataTable(dataColumns, globalPKAnalysis, pkAnalysisDataTable, allSimulations);

            _dataRepositoryTask.ExportToExcel(allDataTables, fileName, launchExcel: true);
        }
Exemple #2
0
        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;
            }

            var dataColumnCache = new Cache <DataColumn, Curve>(onMissingKey: x => null);

            visibleCurves.Each(curve => dataColumnCache[curve.yData] = curve);
            _dataRepositoryTask.ExportToExcel(dataColumnCache.Keys, fileName, col => dataColumnCache[col]?.Name ?? col.Name, _dimensionFactory.MergedDimensionFor);
        }
Exemple #3
0
        private void exportDataRepository(string fileName, IEnumerable <DataColumn> dataRepository)
        {
            var dataTables = _dataRepositoryTask.ToDataTable(dataRepository, new DataColumnExportOptions
            {
                ColumnNameRetriever = x => x.QuantityInfo.PathAsString,
                DimensionRetriever  = _dimensionFactory.MergedDimensionFor
            });

            _dataRepositoryTask.ExportToExcel(dataTables, fileName, true);
        }
Exemple #4
0
        public void Export(DataRepository observedData)
        {
            var file = _dialogCreator.AskForFileToSave(Captions.ExportObservedDataToExcel, Constants.Filter.EXCEL_SAVE_FILE_FILTER, Constants.DirectoryKey.OBSERVED_DATA, observedData.Name);

            if (string.IsNullOrEmpty(file))
            {
                return;
            }

            _dataRepositoryTask.ExportToExcel(observedData, file, launchExcel: true);
        }
Exemple #5
0
        public Task ExportResultsToExcel(IndividualSimulation individualSimulation)
        {
            _buildingBlockTask.LoadResults(individualSimulation);
            if (!individualSimulation.HasResults)
            {
                throw new PKSimException(PKSimConstants.Error.CannotExportResultsPleaseRunSimulation(individualSimulation.Name));
            }

            return(exportToFileAsync(PKSimConstants.UI.ExportSimulationResultsToExcel, Constants.Filter.EXCEL_SAVE_FILE_FILTER, PKSimConstants.UI.DefaultResultsExportNameFor(individualSimulation.Name), async fileName =>
            {
                var dataTables = _dataRepositoryTask.ToDataTable(individualSimulation.DataRepository, x => _quantityDisplayPathMapper.DisplayPathAsStringFor(individualSimulation, x), x => x.Dimension);
                await Task.Run(() => _dataRepositoryTask.ExportToExcel(dataTables, fileName, launchExcel: true));
            }, Constants.DirectoryKey.REPORT));
        }
        public void ExportToExcel <TXValue, TYValue>(ChartData <TXValue, TYValue> chartData, string analysisName) where TXValue : IXValue where TYValue : IYValue
        {
            if (string.IsNullOrEmpty(analysisName))
            {
                analysisName = PKSimConstants.UI.Analysis;
            }

            var fileName = _dialogCreator.AskForFileToSave(PKSimConstants.UI.ExportPopulationAnalysisToExcelTitle, Constants.Filter.EXCEL_SAVE_FILE_FILTER, Constants.DirectoryKey.REPORT, analysisName);

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            var mapper = _chartDataToTableMapperFactory.Create <TXValue, TYValue>();
            var tables = mapper.MapFrom(chartData);

            tables.Each(t => t.TableName = $"{analysisName} {t.TableName}");

            _dataRepositoryTask.ExportToExcel(tables, fileName, launchExcel: true);
        }
        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);
        }