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


C# Worksheet.SetRows方法代码示例

本文整理汇总了C#中Worksheet.SetRows方法的典型用法代码示例。如果您正苦于以下问题:C# Worksheet.SetRows方法的具体用法?C# Worksheet.SetRows怎么用?C# Worksheet.SetRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Worksheet的用法示例。


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

示例1: SS_LoadSheet

        private void SS_LoadSheet(Worksheet sheet, DataRow r, int iFilterCompany = 0)
        {
            // Disable cell editing
            sheet.BeforeCellEdit += (s, e) => e.IsCancelled = true;
            // Set up cell selection
            sheet.CellMouseDown += sheet_CellMouseDown;
            sheet.CellMouseEnter += sheet_CellMouseEnter;
            sheet.CellMouseLeave += sheet_CellMouseLeave;
            sheet.SelectionRangeChanged += sheet_SelectionRangeChanged;

            // Set column headers
            int count = 0;
            DateTime date_from = DateTime.Parse(r["Start"].ToString());
            DateTime date_to = DateTime.Parse(r["Finish"].ToString());
            List<DateTime> dates = new List<DateTime>();

            for (DateTime dt = date_from; dt <= date_to; dt = dt.AddDays(1))
            {
                dates.Add(dt);
                count++;
            }

            sheet.SetCols(count + 1);
            sheet.SetColumnsWidth(1, count, 92);
            sheet.SetColumnsWidth(0, 1, 225);

            count = 1;
            foreach (DateTime date in dates)
            {
                if (!IsWeekend(date))
                {
                    sheet[0, count] = date.ToString("ddd");
                    sheet[1, count] = Convert.ToString(date.ToShortDateString());
                }
                else
                {
                    sheet[0, count] = "S";
                    sheet[1, count] = Convert.ToString(date.Day);
                    sheet.SetColumnsWidth(count, 1, 30);
                }
                sheet.Cells[0, count].Style.HAlign = ReoGridHorAlign.Center;
                sheet.Cells[0, count].Style.VAlign = ReoGridVerAlign.Middle;
                sheet.Cells[0, count].Style.FontName = "Arial";
                sheet.Cells[0, count].Style.FontSize = 8;
                sheet.Cells[0, count].Style.Bold = true;
                sheet.Cells[1, count].Style.HAlign = ReoGridHorAlign.Center;
                sheet.Cells[1, count].Style.VAlign = ReoGridVerAlign.Middle;
                sheet.Cells[1, count].Style.FontName = "Arial";
                sheet.Cells[1, count].Style.FontSize = 8;
                sheet.Cells[1, count].Style.Bold = true;
                count++;
            }

            int iColumnCount = count + 1;

            sheet.RowHeaders[0].Height = 30;
            sheet[0, 0] = "RAW Zone Planner";
            sheet.Cells[0, 0].Style.VAlign = ReoGridVerAlign.Middle;
            sheet.Cells[0, 0].Style.FontName = "Arial";
            sheet.Cells[0, 0].Style.FontSize = 8;
            sheet.Cells[0, 0].Style.Bold = true;

            sheet.RowHeaders[1].Height = 30;
            sheet[1, 0] = r["Name"].ToString();
            sheet.Cells[1, 0].Style.VAlign = ReoGridVerAlign.Middle;
            sheet.Cells[1, 0].Style.FontName = "Arial";
            sheet.Cells[1, 0].Style.FontSize = 8;
            sheet.Cells[1, 0].Style.Bold = true;

            // Set row headers
            DataSet rooms = Program.DB.SelectAll("SELECT ID,Name,IsZone FROM Rooms WHERE ID IN (" + r["Rooms"].ToString() + ");");
            Dictionary<string, string> rows = new Dictionary<string, string>();
            int iZ = 0, iR = 0;
            foreach (DataRow row in rooms.Tables[0].Rows)
            {
                if (row["IsZone"] != DBNull.Value && row["IsZone"].Equals("Y"))
                {
                    rows.Add("z" + row["ID"].ToString(), row["Name"].ToString().Replace("|", " - "));
                    iZ++;
                    continue;
                }

                rows.Add("r" + row["ID"].ToString(), row["Name"].ToString());
                iR++;
            }

            sheet.SetRows(rows.Count + iZ + 2);

            count = 2;
            foreach (KeyValuePair<string, string> entry in rows)
            {
                if (entry.Key.Contains("z"))
                {
                    sheet.SetRowsHeight(count, 1, 15);
                    count++;

                    ReoGridRange rgr = new ReoGridRange(count, 0, 1, iColumnCount);
                    sheet.SetRangeStyles(rgr, new WorksheetRangeStyle
                    {
                        Flag = PlainStyleFlag.BackColor | PlainStyleFlag.FontStyleBold,
//.........这里部分代码省略.........
开发者ID:etechuk,项目名称:hcfcpc,代码行数:101,代码来源:frmMain.cs


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