コード例 #1
0
        void LoadAnalysisData() {
            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);
            foreach(var reportItem in salesReportItems) {
                int rowOffset = frCustomers.IndexOf(reportItem.CustomerName);
                int columnOffset = AnalysisPeriod.MonthOffsetFromStart(reportItem.Date) / 12;
                if(rowOffset < 0 || columnOffset < 0) continue;
                salesReportWorksheet.Cells[14 + rowOffset, 3 + columnOffset * 2].SetValue(reportItem.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(var dataItem in salesDataItems) {
                int rowOffset = AnalysisPeriod.MonthOffsetFromStart(dataItem.Date);
                int columnOffset = states.IndexOf(dataItem.State);
                if(rowOffset < 0 || columnOffset < 0) continue;
                salesDataWorksheet.Cells[6 + rowOffset, 3 + columnOffset].SetValue(dataItem.Total);
            }
            spreadsheetControl.Document.Worksheets.ActiveWorksheet = salesReportWorksheet;
            spreadsheetControl.Document.EndUpdate();
        }
コード例 #2
0
ファイル: ProductAnalysis.cs プロジェクト: ridwanwong/DevAV
        void LoadAnalysisData()
        {
            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);
            foreach (var item in financialReportItems)
            {
                int rowOffset    = frProducts.IndexOf(item.ProductName);
                int columnOffset = AnalysisPeriod.MonthOffsetFromStart(item.Date) / 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 (var item in financialDataItems)
            {
                int rowOffset    = AnalysisPeriod.MonthOffsetFromStart(item.Date);
                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();
        }