当前位置: 首页>>代码示例>>C#>>正文


C# ExcelWorksheet类代码示例

本文整理汇总了C#中ExcelWorksheet的典型用法代码示例。如果您正苦于以下问题:C# ExcelWorksheet类的具体用法?C# ExcelWorksheet怎么用?C# ExcelWorksheet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExcelWorksheet类属于命名空间,在下文中一共展示了ExcelWorksheet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetHourData

        private void SetHourData(Models.Student student, ExcelWorksheet worksheet)
        {
            var collector = new System.Collections.Generic.Dictionary<SpreadsheetExport.Key, int>();
            foreach (var b in student.Behaviors) {
                var key = new SpreadsheetExport.Key { DayOfWeek = b.TimeRecorded.DayOfWeek.ToString(), Hour = b.TimeRecorded.Hour };
                if (collector.ContainsKey(key))
                    collector[key] += 1;
                else
                    collector.Add(key, 1);

            }
            foreach (var key in collector.Keys) {
                var value = key.Hour - 2;
                switch (key.DayOfWeek.ToString()) {
                    case "Monday": worksheet.Cells[5, value].Value = collector[key];
                        break;
                    case "Tuesday": worksheet.Cells[6, value].Value = collector[key];
                        break;
                    case "Wednesday": worksheet.Cells[7, value].Value = collector[key];
                        break;
                    case "Thursday": worksheet.Cells[8, value].Value = collector[key];
                        break;
                    case "Friday": worksheet.Cells[9, value].Value = collector[key];
                        break;
                    default:
                        break;
                }
            }
        }
开发者ID:stuffihavemade,项目名称:base_station_code,代码行数:29,代码来源:SpreadsheetExporter.cs

示例2: ApplyColumnsAutoWidth

        private static void ApplyColumnsAutoWidth(ExcelWorksheet ws)
        {
            int columnCount = ws.CalculateMaxUsedColumns();

            for (int i = 0; i < columnCount; i++)
                ws.Columns[i].AutoFit();
        }
开发者ID:Okiana,项目名称:Team-Diosma,代码行数:7,代码来源:FinancialReportGenerator.cs

示例3: ExcelColumn

		/// <summary>
		/// Creates a new instance of the ExcelColumn class.  
		/// For internal use only!
		/// </summary>
		/// <param name="Worksheet"></param>
		/// <param name="col"></param>
		protected internal ExcelColumn(ExcelWorksheet Worksheet, int col)
        {
            _worksheet = Worksheet;
            _columnMin = col;
            _columnMax = col;
            _width = _worksheet.DefaultColWidth;
        }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:13,代码来源:ExcelColumn.cs

示例4: Import

        public void Import(ExcelWorksheet sheet, List<EntityMetadata> emds, IOrganizationService service)
        {
            var rmds = new List<OneToManyRelationshipMetadata>();

            foreach (var row in sheet.Rows.Where(r => r.Index != 0).OrderBy(r => r.Index))
            {
                var rmd = rmds.FirstOrDefault(r => r.MetadataId == new Guid(row.Cells[1].Value.ToString()));
                if (rmd == null)
                {
                    var currentEntity = emds.FirstOrDefault(e => e.LogicalName == row.Cells[0].Value.ToString());
                    if (currentEntity == null)
                    {
                        var request = new RetrieveEntityRequest
                        {
                            LogicalName = row.Cells[0].Value.ToString(),
                            EntityFilters = EntityFilters.Relationships
                        };

                        var response = ((RetrieveEntityResponse) service.Execute(request));
                        currentEntity = response.EntityMetadata;

                        emds.Add(currentEntity);
                    }

                    rmd =
                        currentEntity.OneToManyRelationships.FirstOrDefault(
                            r => r.SchemaName == row.Cells[2].Value.ToString());
                    if (rmd == null)
                    {
                        rmd =
                            currentEntity.ManyToOneRelationships.FirstOrDefault(
                                r => r.SchemaName == row.Cells[2].Value.ToString());
                    }

                    rmds.Add(rmd);
                }

                int columnIndex = 4;

                rmd.AssociatedMenuConfiguration.Label = new Label();

                while (row.Cells[columnIndex].Value != null)
                {
                    rmd.AssociatedMenuConfiguration.Label.LocalizedLabels.Add(
                        new LocalizedLabel(row.Cells[columnIndex].Value.ToString(),
                            int.Parse(sheet.Cells[0, columnIndex].Value.ToString())));

                    columnIndex++;
                }
            }

            foreach (var rmd in rmds)
            {
                var request = new UpdateRelationshipRequest
                {
                    Relationship = rmd,
                };
                service.Execute(request);
            }
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:60,代码来源:RelationshipTranslation.cs

示例5: RangeDataValidation

 public RangeDataValidation(ExcelWorksheet worksheet, string address)
 {
     Require.Argument(worksheet).IsNotNull("worksheet");
     Require.Argument(address).IsNotNullOrEmpty("address");
     _worksheet = worksheet;
     _address = address;
 }
开发者ID:acinep,项目名称:epplus,代码行数:7,代码来源:RangeDataValidation.cs

示例6: ExcelNamedRange

        /// <summary>
        /// A named range
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="nameSheet">The sheet containing the name. null if its a global name</param>
        /// <param name="sheet">Sheet where the address points</param>
        /// <param name="address">The address</param>
        public ExcelNamedRange(string name, ExcelWorksheet nameSheet , ExcelWorksheet sheet, string address) :
            base(sheet, address)
        {
            Name = name;
            _sheet = nameSheet;

        }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:14,代码来源:ExcelNamedRange.cs

示例7: SetMonthData

 private void SetMonthData(Models.Student student, ExcelWorksheet worksheet)
 {
     int m = 0, t = 0, w = 0, th = 0, f = 0;
     foreach (var b in student.Behaviors) {
         {
             switch (b.TimeRecorded.DayOfWeek.ToString()) {
                 case "Monday": m++;
                     break;
                 case "Tuesday": t++;
                     break;
                 case "Wednesday": w++;
                     break;
                 case "Thursday": th++;
                     break;
                 case "Friday": f++;
                     break;
             }
         }
         worksheet.Cells[2, 5].Value = m;
         worksheet.Cells[2, 6].Value = t;
         worksheet.Cells[2, 7].Value = w;
         worksheet.Cells[2, 8].Value = th;
         worksheet.Cells[2, 9].Value = f;
     }
 }
开发者ID:stuffihavemade,项目名称:base_station_code,代码行数:25,代码来源:SpreadsheetExporter.cs

示例8: ExcelRange

 internal ExcelRange(ExcelWorksheet sheet, int fromRow, int fromCol, int toRow, int toCol)
     : base(sheet)
 {
     _fromRow = fromRow;
     _fromCol = fromCol;
     _toRow = toRow;
     _toCol = toCol;
 }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:8,代码来源:ExcelRange.cs

示例9: ExcelCell

 internal ExcelCell(ExcelWorksheet worksheet, string cellAddress)
 {
     _worksheet = worksheet;
     GetRowColFromAddress(cellAddress, out _row, out _col);
     if (_col < worksheet._minCol) worksheet._minCol = _col;
     if (_col > worksheet._maxCol) worksheet._maxCol = _col;
     _sharedFormulaID = int.MinValue;
     IsRichText = false;
 }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:9,代码来源:ExcelCell.cs

示例10: ExcelCommentCollection

 internal ExcelCommentCollection(ExcelPackage pck, ExcelWorksheet ws, XmlNamespaceManager ns)
 {
     CommentXml = new XmlDocument();
     CommentXml.PreserveWhitespace = false;
     NameSpaceManager=ns;
     Worksheet=ws;
     CreateXml(pck);
     AddCommentsFromXml();
 }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:9,代码来源:ExcelCommentCollection.cs

示例11: ExcelConditionalFormattingRule

    /****************************************************************************************/

    #region Constructors
    /// <summary>
    /// Initialize the <see cref="ExcelConditionalFormattingRule"/>
    /// </summary>
    /// <param name="type"></param>
    /// <param name="address"></param>
    /// <param name="priority">Used also as the cfRule unique key</param>
    /// <param name="worksheet"></param>
    /// <param name="itemElementNode"></param>
    /// <param name="namespaceManager"></param>
    internal ExcelConditionalFormattingRule(
      eExcelConditionalFormattingRuleType type,
      ExcelAddress address,
      int priority,
      ExcelWorksheet worksheet,
      XmlNode itemElementNode,
      XmlNamespaceManager namespaceManager)
      : base(
        namespaceManager,
        itemElementNode)
    {
      Require.Argument(address).IsNotNull("address");

  	  // While MSDN states that 1 is the "highest priority," it also defines this
	  // field as W3C XML Schema int, which would allow values less than 1. Excel
	  // itself will, on occasion, use a value of 0, so this check will allow a 0.
      Require.Argument(priority).IsInRange(0, int.MaxValue, "priority");

      Require.Argument(worksheet).IsNotNull("worksheet");

      _type = type;
      _worksheet = worksheet;
      SchemaNodeOrder = _worksheet.SchemaNodeOrder;

      if (itemElementNode == null)
      {
        // Create/Get the <cfRule> inside <conditionalFormatting>
        itemElementNode = CreateComplexNode(
          _worksheet.WorksheetXml.DocumentElement,
          string.Format(
            "{0}[{1}='{2}']/{1}='{2}'/{3}[{4}='{5}']/{4}='{5}'",
          //{0}
            ExcelConditionalFormattingConstants.Paths.ConditionalFormatting,
          // {1}
            ExcelConditionalFormattingConstants.Paths.SqrefAttribute,
          // {2}
            address.AddressSpaceSeparated,          //CF node don't what to have comma between multi addresses, use space instead.
          // {3}
            ExcelConditionalFormattingConstants.Paths.CfRule,
          //{4}
            ExcelConditionalFormattingConstants.Paths.PriorityAttribute,
          //{5}
            priority));
      }

      // Point to <cfRule>
      TopNode = itemElementNode;

      Address = address;
      Priority = priority;
      Type = type;
      if (DxfId >= 0)
      {
          worksheet.Workbook.Styles.Dxfs[DxfId].AllowChange = true;  //This Id is referenced by CF, so we can use it when we save.
          _style = worksheet.Workbook.Styles.Dxfs[DxfId].Clone();    //Clone, so it can be altered without effecting other dxf styles
      }
    }
开发者ID:Eagle-Chan,项目名称:KIS,代码行数:69,代码来源:ExcelConditionalFormattingRule.cs

示例12: SheetControl

        /// <summary>
        /// Creates new object of type SheetControl and imports data from ExcelWorksheet if available
        /// </summary>
        /// <param name="worksheet">Optional. Worksheet to import</param>
        public SheetControl(ExcelWorksheet worksheet = null)
        {
            InitializeComponent();

            // Assign argument
            this.worksheet = worksheet;

            ReloadSheet();
        }
开发者ID:AleksandarDev,项目名称:Project---Metro-Tables,代码行数:13,代码来源:SheetControl.xaml.cs

示例13: Create

        internal static DependencyChain Create(ExcelWorksheet ws, string Formula, ExcelCalculationOption options)
        {
            ws.CheckSheetType();
            var depChain = new DependencyChain();

            GetChain(depChain, ws.Workbook.FormulaParser.Lexer, ws, Formula, options);
            
            return depChain;
        }
开发者ID:Eagle-Chan,项目名称:KIS,代码行数:9,代码来源:DependenyChainFactory.cs

示例14: ExcelConditionalFormattingThreeColorScale

        /// <summary>
        /// 
        /// </summary>
        /// <param name="address"></param>
        /// <param name="priority"></param>
        /// <param name="worksheet"></param>
        /// <param name="itemElementNode"></param>
        /// <param name="namespaceManager"></param>
        internal ExcelConditionalFormattingThreeColorScale(
            ExcelAddress address,
            int priority,
            ExcelWorksheet worksheet,
            XmlNode itemElementNode,
            XmlNamespaceManager namespaceManager)
            : base(eExcelConditionalFormattingRuleType.ThreeColorScale,
        address,
        priority,
        worksheet,
        itemElementNode,
        (namespaceManager == null) ? worksheet.NameSpaceManager : namespaceManager)
        {
            if (itemElementNode == null)
            {
                // Create the <colorScale> node inside the <cfRule> node
                var colorScaleNode = CreateComplexNode(
                  Node,
                  ExcelConditionalFormattingConstants.Paths.ColorScale);

                // LowValue default
                LowValue = new ExcelConditionalFormattingColorScaleValue(
                  eExcelConditionalFormattingValueObjectPosition.Low,
                  eExcelConditionalFormattingValueObjectType.Min,
                  ColorTranslator.FromHtml(ExcelConditionalFormattingConstants.Colors.CfvoLowValue),
                  eExcelConditionalFormattingRuleType.ThreeColorScale,
                  address,
                  priority,
                  worksheet,
                  NameSpaceManager);

                // MiddleValue default
                MiddleValue = new ExcelConditionalFormattingColorScaleValue(
                  eExcelConditionalFormattingValueObjectPosition.Middle,
                  eExcelConditionalFormattingValueObjectType.Percent,
                  ColorTranslator.FromHtml(ExcelConditionalFormattingConstants.Colors.CfvoMiddleValue),
                  50,
                  string.Empty,
                  eExcelConditionalFormattingRuleType.ThreeColorScale,
                  address,
                  priority,
                  worksheet,
                  NameSpaceManager);

                // HighValue default
                HighValue = new ExcelConditionalFormattingColorScaleValue(
                  eExcelConditionalFormattingValueObjectPosition.High,
                  eExcelConditionalFormattingValueObjectType.Max,
                  ColorTranslator.FromHtml(ExcelConditionalFormattingConstants.Colors.CfvoHighValue),
                  eExcelConditionalFormattingRuleType.ThreeColorScale,
                  address,
                  priority,
                  worksheet,
                  NameSpaceManager);
            }
        }
开发者ID:princeoffoods,项目名称:EPPlus,代码行数:64,代码来源:ExcelConditionalFormattingThreeColorScale.cs

示例15: GetTableDescriptor

 private static TableDescriptor GetTableDescriptor(ExcelWorksheet worksheet, ContentLoadType type)
 {
     var countOfKeys = 2;
     if (type.HasFlag(ContentLoadType.Column))
     {
         countOfKeys++;
     }
     var descriptor = TableDescriptor.GetReadDynamic(worksheet.Name, new TableKeyDescriptor((new[] {1, 2, 3}).Take(countOfKeys).ToArray()), 2);
     return descriptor;
 }
开发者ID:HedinRakot,项目名称:Zierer,代码行数:10,代码来源:DataMigration.cs


注:本文中的ExcelWorksheet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。