コード例 #1
0
        private SOARolePropertyRow GenerateMatrixRow(SOARole role, RowNode rowNode, NamedLocationCollection locations, int index)
        {
            SOARolePropertyRow mRow = new SOARolePropertyRow(role);

            mRow.RowNumber = index;

            int emptyCellCount = 0;

            foreach (var row in this.Definition)
            {
                CellLocation location = locations[row.Name];

                CellNode cell = rowNode.GetCellByIndex(location.Column);

                SOARolePropertyValue mCell = new SOARolePropertyValue(row);

                mCell.Value = cell.Data.InnerText.Trim();

                mRow.Values.Add(mCell);

                switch (row.Name)
                {
                    case "Operator":
                        mRow.Operator = cell.Data.InnerText;
                        break;
                    case "OperatorType":
                        SOARoleOperatorType opType = SOARoleOperatorType.User;
                        Enum.TryParse(cell.Data.InnerText, out opType);
                        mRow.OperatorType = opType;
                        break;
                    default:
                        if (mCell.Value.IsNullOrEmpty())
                            emptyCellCount++;
                        break;
                }
            }

            role.Rows.Add(mRow);

            return mRow;
        }
コード例 #2
0
ファイル: TableNode.cs プロジェクト: jerryshi2007/AK47Source
		public override void FromXmlNode(XmlNode node)
		{
			this.ExpandedColumnCount = XmlHelper.GetAttributeValue(node, "ExpandedColumnCount", 0);
			this.ExpandedRowCount = XmlHelper.GetAttributeValue(node, "ExpandedRowCount", 0);

			this.DefaultColumnWidth = XmlHelper.GetAttributeValue(node, "DefaultColumnWidth", 0.0);
			this.DefaultRowHeight = XmlHelper.GetAttributeValue(node, "DefaultRowHeight", 0.0);
			this.LeftCell = XmlHelper.GetAttributeValue(node, "LeftCell", 0);
			this.TopCell = XmlHelper.GetAttributeValue(node, "TopCell", 0);
			this.StyleID = XmlHelper.GetAttributeText(node, "StyleID");

			this.FullColumns = XmlHelper.GetAttributeValue(node, "FullColumns", Namespaces.x, false);
			this.FullRows = XmlHelper.GetAttributeValue(node, "FullRows", Namespaces.x, false);

			XmlNodeList columnNodes = node.SelectNodes("ss:Column", Namespaces.GetNamespaceManager());

			foreach (XmlNode columnNode in columnNodes)
			{
				ColumnNode column = new ColumnNode();

				column.FromXmlNode(columnNode);

				Columns.Add(column);
			}

			XmlNodeList rowNodes = node.SelectNodes("ss:Row", Namespaces.GetNamespaceManager());

			foreach (XmlNode rowNode in rowNodes)
			{
				RowNode row = new RowNode();

				row.FromXmlNode(rowNode);

				Rows.Add(row);
			}
		}
コード例 #3
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);
			}
		}
コード例 #4
0
		/// <summary>
		/// 填充Excel Xml的标题列
		/// </summary>
		/// <param name="workbook"></param>
		/// <param name="definition"></param>
		/// <param name="propertySheetName"></param>
		private static void FillWorkSheetTitle(WorkbookNode workbook, SOARolePropertyDefinitionCollection definition, string propertySheetName)
		{
			WorksheetNode worksheet = GetWorksheetFromWorkbook(workbook, propertySheetName);

			worksheet.Names.Clear();
			workbook.Names.Clear();

			worksheet.Table.Rows[1].Cells.Clear();

			int row = 3;
			int column = 1;

			RowNode titleRow = null;

			if (worksheet.Table.Rows.Count > 0)
				titleRow = worksheet.Table.Rows[1];
			else
			{
				titleRow = new RowNode();
				worksheet.Table.Rows.Add(titleRow);
			}

			foreach (SOARolePropertyDefinition dd in definition)
			{
				NamedRangeNode range = new NamedRangeNode();

				range.Name = dd.Name;

				range.RefersTo = string.Format("={0}!R{1}C{2}", worksheet.Name, row, column);
				workbook.Names.Add(range);

				CellNode cell = new CellNode();

				cell.Data.Value = dd.Description.IsNotEmpty() ? dd.Description : dd.Name;

				cell.StyleID = "s17";

				titleRow.Cells.Add(cell);

				column++;
			}
		}
コード例 #5
0
		private static void FillIntoWorksheet(WorksheetNode worksheet, DataView view, DataViewExportOptions options)
		{
			foreach (DataColumn column in view.Table.Columns)
			{
				if (options.IgnoredColumnNames.Exists(c => c == column.ColumnName) == false)
				{
					ColumnNode columnNode = new ColumnNode();

					columnNode.Caption = column.ColumnName;

					options.OnDateViewExportColumnHeader(column, columnNode, options.Context);

					worksheet.Table.Columns.Add(columnNode);
				}
			}

			bool isFirstRow = true;

			if (options.ExportColumnHeader)
			{
				RowNode rowNode = BuildHeaderRow(view.Table.Columns);

				if (options.StartRow > 0)
					rowNode.Index = options.StartRow;

				worksheet.Table.Rows.Add(rowNode);

				isFirstRow = false;
			}

			foreach (DataRowView drv in view)
			{
				RowNode rowNode = new RowNode();

				if (isFirstRow)
				{
					if (options.StartRow > 0)
						rowNode.Index = options.StartRow;

					isFirstRow = false;
				}

				bool isFirstColumn = true;

				foreach (DataColumn column in view.Table.Columns)
				{
					if (options.IgnoredColumnNames.Exists(c => c == column.ColumnName) == false)
					{
						CellNode cellNode = new CellNode();

						cellNode.Data.Type = GetCellDataType(column);
						object dataValue = drv[column.ColumnName];

						if (dataValue != null)
						{
							if (cellNode.Data.Type == CellDataType.DateTime && (dataValue is DateTime))
							{
								cellNode.Data.Value = string.Format("{0:yyyy-MM-ddTHH:mm:ss}", dataValue);
								cellNode.StyleID = "NormalDateTime";
							}
							else
								cellNode.Data.Value = dataValue.ToString();
						}

						if (isFirstColumn)
						{
							if (options.StartColumn > 0)
								cellNode.Index = options.StartColumn;

							isFirstColumn = false;
						}

						options.OnDateViewExportColumnData(column, cellNode, dataValue, options.Context);

						rowNode.Cells.Add(cellNode);
					}
				}

				worksheet.Table.Rows.Add(rowNode);
			}
		}
コード例 #6
0
		private static RowNode BuildHeaderRow(DataColumnCollection columns)
		{
			RowNode rowNode = new RowNode();

			foreach (DataColumn column in columns)
			{
				CellNode cellNode = new CellNode();

				cellNode.Data.Value = column.ColumnName;

				rowNode.Cells.Add(cellNode);
			}

			return rowNode;
		}
コード例 #7
0
        private static void FillIntoWorksheet(WorksheetNode worksheet, DataView view, DataViewExportOptions options)
        {
            foreach (DataColumn column in view.Table.Columns)
            {
                if (options.IgnoredColumnNames.Exists(c => c == column.ColumnName) == false)
                {
                    ColumnNode columnNode = new ColumnNode();

                    columnNode.Caption = column.ColumnName;

                    options.OnDateViewExportColumnHeader(column, columnNode, options.Context);

                    worksheet.Table.Columns.Add(columnNode);
                }
            }

            bool isFirstRow = true;

            if (options.ExportColumnHeader)
            {
                RowNode rowNode = BuildHeaderRow(view.Table.Columns);

                if (options.StartRow > 0)
                {
                    rowNode.Index = options.StartRow;
                }

                worksheet.Table.Rows.Add(rowNode);

                isFirstRow = false;
            }

            foreach (DataRowView drv in view)
            {
                RowNode rowNode = new RowNode();

                if (isFirstRow)
                {
                    if (options.StartRow > 0)
                    {
                        rowNode.Index = options.StartRow;
                    }

                    isFirstRow = false;
                }

                bool isFirstColumn = true;

                foreach (DataColumn column in view.Table.Columns)
                {
                    if (options.IgnoredColumnNames.Exists(c => c == column.ColumnName) == false)
                    {
                        CellNode cellNode = new CellNode();

                        cellNode.Data.Type = GetCellDataType(column);
                        object dataValue = drv[column.ColumnName];

                        if (dataValue != null)
                        {
                            if (cellNode.Data.Type == CellDataType.DateTime && (dataValue is DateTime))
                            {
                                cellNode.Data.Value = string.Format("{0:yyyy-MM-ddTHH:mm:ss}", dataValue);
                                cellNode.StyleID    = "NormalDateTime";
                            }
                            else
                            {
                                cellNode.Data.Value = dataValue.ToString();
                            }
                        }

                        if (isFirstColumn)
                        {
                            if (options.StartColumn > 0)
                            {
                                cellNode.Index = options.StartColumn;
                            }

                            isFirstColumn = false;
                        }

                        options.OnDateViewExportColumnData(column, cellNode, dataValue, options.Context);

                        rowNode.Cells.Add(cellNode);
                    }
                }

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