예제 #1
0
        private static void FillMatrixRowsToWorksheet(WorkbookNode workbook, WfMatrix matrix, bool roleAsPerson)
        {
            NamedLocationCollection locations = workbook.Names.ToLocations();

            locations.SortByColumn();

            WorksheetNode worksheet       = workbook.Worksheets[GetWorksheet(locations)];
            int           startRowIndex   = GetStartRow(locations);
            int           currentRowIndex = -1;

            foreach (WfMatrixRow matrixRow in matrix.Rows)
            {
                RowNode row = new RowNode();

                if (currentRowIndex == -1)
                {
                    currentRowIndex = startRowIndex + 1;
                    row.Index       = currentRowIndex;
                }

                foreach (CellLocation location in locations)
                {
                    CellNode     cell  = new CellNode();
                    WfMatrixCell mCell = matrixRow.Cells.Find(c => c.Definition.DimensionKey == location.Name);

                    if (mCell != null)
                    {
                        cell.Data.Value = GetCellValue(roleAsPerson, mCell, matrixRow);
                    }
                    row.Cells.Add(cell);
                }

                worksheet.Table.Rows.Add(row);
            }
        }
예제 #2
0
        //导出带数据的Excel
        private static void FillMatrixRowsToWorksheet(WorkbookNode workbook, SOARolePropertyRowCollection rows)
        {
            NamedLocationCollection locations = workbook.Names.ToLocations();

            locations.SortByColumn();

            WorksheetNode worksheet       = workbook.Worksheets[GetWorksheet(locations)];
            int           startRowIndex   = GetStartRow(locations);
            int           currentRowIndex = -1;

            foreach (SOARolePropertyRow matrixRow in rows)
            {
                RowNode row = new RowNode();

                if (currentRowIndex == -1)
                {
                    currentRowIndex = startRowIndex + 1;
                    row.Index       = currentRowIndex;
                }

                for (int i = 0; i < locations.Count; i++)
                {
                    CellNode cell = new CellNode();

                    CellLocation location = locations[i];

                    SOARolePropertyValue propertyValue = matrixRow.Values.FindByColumnName(location.Name);

                    string dataValue = null;

                    if (propertyValue != null)
                    {
                        dataValue = propertyValue.Value;
                    }
                    else
                    {
                        switch (location.Name.ToLower())
                        {
                        case "operatortype":
                            dataValue = matrixRow.OperatorType.ToString();
                            break;

                        case "operator":
                            dataValue = matrixRow.Operator;
                            break;
                        }
                    }

                    if (dataValue != null)
                    {
                        cell.Data.Value = dataValue;
                    }
                    else
                    {
                        cell.Data.Value = string.Empty;
                    }

                    row.Cells.Add(cell);
                }

                worksheet.Table.Rows.Add(row);
            }
        }