Ejemplo n.º 1
0
        private void AddSelectedSettings(IProjectStatistic statistic, WorksheetPart worksheetPart)
        {
            InsertText(3, "A", "Project Version:", true, worksheetPart);
            InsertText(3, "B", statistic.VersionName, false, worksheetPart);
            InsertText(4, "A", "Timeframe:", true, worksheetPart);
            string timeframe = statistic.StartDate.ToString("dd/MM/yyyy") + "  -  " + statistic.EndDate.ToString("dd/MM/yyyy");

            InsertText(4, "B", timeframe, false, worksheetPart);
            InsertText(5, "A", "Items:", true, worksheetPart);
            string itemfilter = string.Empty;

            if (statistic.ItemFilter[0])
            {
                itemfilter = "Ceated";
            }
            else if (statistic.ItemFilter[1])
            {
                itemfilter = "Revised";
            }
            else if (statistic.ItemFilter[2])
            {
                itemfilter = "Resolved";
            }
            else if (statistic.ItemFilter[3])
            {
                itemfilter = "Closed";
            }
            InsertText(5, "B", itemfilter, false, worksheetPart);
        }
 public ProjectStatisticViewModel(IEventAggregator eventaggregator, IProject selectedproject, IExportService exportservice,
                                  IDiagramService diagramservice, IGeneralData generaldata, IProjectStatistic statistic)
 {
     this.SelectedProject  = selectedproject;
     this._statisticmodel  = statistic;
     this._generaldata     = generaldata;
     this.DiagramService   = diagramservice;
     this._exportservice   = exportservice;
     this._eventAggregator = eventaggregator;
     this._eventAggregator.GetEvent <SelectedProjectEvent>().Subscribe(OnNewProjectSelection);
     this._eventAggregator.GetEvent <UpdatedProjectEvent>().Subscribe(OnProjectUpdated);
     this.CalculateCommand = new DelegateCommand(this.OnCalculateCommand);
     this.ExportCommand    = new DelegateCommand(this.OnExportCommand);
     this.StartDate        = DateTime.Now;
     this.EndDate          = DateTime.Now;
     this.CanCalculate     = false;
     this.CanExport        = false;
 }
Ejemplo n.º 3
0
        private void AddDiagramData(IProjectStatistic statistic, WorksheetPart worksheetPart)
        {
            InsertText(7, "A", statistic.DiagramSortSelected, true, worksheetPart);
            InsertText(7, "B", "Count", true, worksheetPart);
            InsertText(7, "C", "Percent", true, worksheetPart);
            uint rowcount = 8;

            foreach (KeyValuePair <string, int> data in statistic.ChartData)
            {
                string tmpkey = data.Key;
                if (tmpkey[tmpkey.Length - 1] == '*')
                {
                    tmpkey = tmpkey.Remove(tmpkey.Length - 1);
                }
                InsertText(rowcount, "A", tmpkey, false, worksheetPart);
                InsertText(rowcount, "B", data.Value.ToString(), false, worksheetPart);
                InsertText(rowcount, "C", ((Convert.ToDouble(data.Value) / statistic.ItemsTotal) * 100).ToString("0.00"), false, worksheetPart);
                ++rowcount;
            }
            InsertText(rowcount, "A", "Total:", true, worksheetPart);
            InsertText(rowcount, "B", statistic.ItemsTotal.ToString(), true, worksheetPart);
            InsertText(rowcount, "C", "100 %", true, worksheetPart);
        }
Ejemplo n.º 4
0
        public void ExportData(string exportpath, string imagepath, IProject project, IProjectStatistic statistic)
        {
            // Create a spreadsheet document by supplying the filepath.
            SpreadsheetDocument exceldoc = SpreadsheetDocument.Create(exportpath, SpreadsheetDocumentType.Workbook);
            // Add a WorkbookPart to the document.
            WorkbookPart workbookpart = exceldoc.AddWorkbookPart();

            workbookpart.Workbook = new Workbook();
            // Add a WorksheetPart to the WorkbookPart.
            WorksheetPart worksheetPart = workbookpart.AddNewPart <WorksheetPart>();

            worksheetPart.Worksheet = new Worksheet(new SheetData());
            // Add Sheets to the Workbook.
            Sheets sheets = workbookpart.Workbook.AppendChild <Sheets>(new Sheets());
            // Append a new worksheet and associate it with the workbook.
            Sheet sheet = new Sheet()
            {
                Id = workbookpart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "data"
            };

            sheets.Append(sheet);
            // Add a StylesPart to the WorkbookPart ( Stores different font settings, etc. )
            WorkbookStylesPart stylespart = exceldoc.WorkbookPart.AddNewPart <WorkbookStylesPart>();

            stylespart.Stylesheet = CreateStyleSheet();
            // Save the workbook ( with one worksheet and one stylesheet )
            stylespart.Stylesheet.Save();
            workbookpart.Workbook.Save();

            // Add all the Excel-Table-Data, at hardcoded positions
            AddGeneralInformation(project, worksheetPart);
            AddSelectedSettings(statistic, worksheetPart);
            AddDiagramData(statistic, worksheetPart);
            // Add the Diagram image, if one exists
            if (imagepath != string.Empty)
            {
                InsertImage(worksheetPart, imagepath);
            }

            // Close the document.
            exceldoc.Close();
        }