Exemple #1
0
        void LoadData()
        {
            CustomerAnalysisViewModel ViewModel = (CustomerAnalysisViewModel)this.DataContext;

            spreadsheetControl.Document.BeginUpdate();
            var salesReportWorksheet = spreadsheetControl.Document.Worksheets["Sales Report"];
            var salesReportItems     = ViewModel.GetSalesReport().ToList(); // materialize
            var frCustomers          = salesReportItems
                                       .Select(i => i.CustomerName)
                                       .Distinct()
                                       .OrderBy(i => i).ToList();

            salesReportWorksheet.Import(frCustomers, 14, 1, true);
            var startReportsDate = salesReportItems.Min(x => x.Date);

            foreach (CustomersAnalysis.Item item in salesReportItems)
            {
                int rowOffset    = frCustomers.IndexOf(item.CustomerName);
                int columnOffset = (int)(AnalysisPeriod.GetMonthOffsetFromStart(item.Date, startReportsDate) / 12);
                if (rowOffset < 0 || columnOffset < 0)
                {
                    continue;
                }
                salesReportWorksheet.Cells[14 + rowOffset, 3 + columnOffset * 2].SetValue(item.Total);
            }
            var salesDataWorksheet = spreadsheetControl.Document.Worksheets["Sales Data"];
            var salesDataItems     = ViewModel.GetSalesData().ToList(); // materialize
            var states             = salesDataItems.Select(i => i.State).Distinct().OrderBy(i => i).ToList();

            salesDataWorksheet.Import(ViewModel.GetStates(states), 5, 3, false);
            foreach (CustomersAnalysis.Item item in salesDataItems)
            {
                int rowOffset    = AnalysisPeriod.GetMonthOffsetFromStart(item.Date, startReportsDate) - 1;
                int columnOffset = states.IndexOf(item.State);
                if (rowOffset < 0 || columnOffset < 0)
                {
                    continue;
                }
                salesDataWorksheet.Cells[6 + rowOffset, 3 + columnOffset].SetValue(item.Total);
            }
            spreadsheetControl.Document.Worksheets.ActiveWorksheet = salesReportWorksheet;
            spreadsheetControl.Document.EndUpdate();
        }
Exemple #2
0
        void LoadData()
        {
            ProductAnalysisViewModel ViewModel = (ProductAnalysisViewModel)this.DataContext;

            spreadsheetControl.Document.BeginUpdate();
            var financialReportWorksheet = spreadsheetControl.Document.Worksheets["Financial Report"];
            var financialReportItems     = ViewModel.GetFinancialReport().ToList(); // materialize
            var frProducts = financialReportItems
                             .Select(i => i.ProductName)
                             .Distinct()
                             .OrderBy(i => i).ToList();

            financialReportWorksheet.Import(frProducts, 17, 1, true);
            var startReportsDate = financialReportItems.Min(x => x.Date);

            foreach (ProductsAnalysis.Item item in financialReportItems)
            {
                int rowOffset    = frProducts.IndexOf(item.ProductName);
                int columnOffset = (int)(AnalysisPeriod.GetMonthOffsetFromStart(item.Date, startReportsDate) / 12);
                if (rowOffset < 0 || columnOffset < 0)
                {
                    continue;
                }
                financialReportWorksheet.Cells[17 + rowOffset, 3 + columnOffset * 2].SetValue(item.Total);
            }
            var financialDataWorksheet = spreadsheetControl.Document.Worksheets["Financial Data"];
            var financialDataItems     = ViewModel.GetFinancialData().ToList(); // materialize

            foreach (ProductsAnalysis.Item item in financialDataItems)
            {
                int rowOffset    = AnalysisPeriod.GetMonthOffsetFromStart(item.Date, startReportsDate) - 1;
                int columnOffset = GetColumnIndex(item.ProductCategory);
                if (rowOffset < 0 || columnOffset < 0)
                {
                    continue;
                }
                financialDataWorksheet.Cells[6 + rowOffset, 3 + columnOffset].SetValue(item.Total);
            }
            spreadsheetControl.Document.Worksheets.ActiveWorksheet = financialReportWorksheet;
            spreadsheetControl.Document.EndUpdate();
        }