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


C# IXLWorksheet.Rows方法代码示例

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


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

示例1: getTotalHeight

        public static double getTotalHeight(IXLWorksheet ws, int startRow)
        {
            var totalHeight = 0.0;
            foreach (var row in ws.Rows(startRow, ws.LastRowUsed().RowNumber()))
            {
                totalHeight += row.Height;
            }

            return totalHeight;

        }
开发者ID:vadimPoliansky,项目名称:TestPR_Dev,代码行数:11,代码来源:ExcelFunctions.cs

示例2: AddContainerInfo

        public void AddContainerInfo(IXLWorksheet ws, Container container)
        {
            ws.Cell("A1").SetValue(container.ExporterName).Style.Font.FontSize = 20;
            ws.Range("A1:E1").Merge();

            ws.Cell("A2").SetValue(container.ExporterAddress).Style.Alignment.WrapText = true;
            ws.Range("A2:B3").Merge();

            ws.Cell("A5").SetValue("Shipped Per");
            ws.Cell("B5").SetValue(container.ShippedPer);
            ws.Range("B5:C5").Merge();

            ws.Cell("A6").SetValue("On/About");
            ws.Cell("B6").SetValue(container.OnAbout);
            ws.Range("B6:C6").Merge();

            ws.Cell("A7").SetValue("From");
            ws.Cell("B7").SetValue(container.From);
               // ws.Row(7)
              //  .Style
             //   .Alignment.SetVertical(XLAlignmentVerticalValues.Top)
             //   .Alignment.SetWrapText(true);
            ws.Range("B7:C7").Merge();
            ws.Row(7).Height = 70;

            ws.Cell("A8").SetValue("Airway Bill No. \nor B/L No.");
            ws.Cell("B8").SetValue(container.AirwayBillNumber);
            ws.Range("B8:C8").Merge();

            ws.Row(8).Height = 30;
               // ws.Row(8).Style.Alignment.SetWrapText(true);

            ws.Cell("A9").SetValue("Letter of\nCredit No.");
            ws.Cell("B9").SetValue(container.LetterOfCreditNumber);
            ws.Range("B9:C9").Merge();
            ws.Row(9).Height = 30;
            ws.Cell("A10").SetValue("Drawn Under");
            ws.Cell("B10").SetValue(container.DrawnUnder)
                .Style
                    .Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
               //         .Alignment.SetWrapText(true);
            ws.Range("B10:C10").Merge();
            ws.Row(10).Height = 70;
             //   ws.Row(10).Style.Alignment.SetVertical(XLAlignmentVerticalValues.Top);

            ws.Range("A1:A10").Style.Font.Bold = true;
            ws.Range("B5:C10").Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            //    ws.Range("B5:C10").Style.Alignment.WrapText = true;

            ws.Rows("5:10").Style.Alignment.SetWrapText(true)
                .Alignment.SetVertical(XLAlignmentVerticalValues.Top);

            //Importer
            ws.Cell("E5").SetValue(container.ImporterName +
                                        "\n" + container.ImporterAddress +
                                        "\n" + "(TAX CERTIFICATE NO. " + container.ImporterTaxCertificateNumber + ")")
                                        .Style
                                            .Alignment.SetVertical(XLAlignmentVerticalValues.Top)
                                            .Alignment.SetWrapText();

            ws.Range("E5:H10").Merge().Style.Border.OutsideBorder = XLBorderStyleValues.Medium;

            //Container Number + Container Date
            ws.Cell("F2").SetValue("INVOICE NO:");
            ws.Cell("G2").SetValue(container.CustomsInvoiceNumber);

            ws.Cell("F3").SetValue("DATE:");
            ws.Cell("G3").SetValue(container.Date);

            ws.Range("F2:F3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
            ws.Range("G2:H2").Merge();
            ws.Range("G3:H3").Merge();
            ws.Range("G2:G3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
            ws.Range("F2:H3").Style.Font.Bold = true;
        }
开发者ID:punitjajodia,项目名称:raushan,代码行数:75,代码来源:TmpExportToExcelController.cs

示例3: OutputOverdues


//.........这里部分代码省略.........
                XLColor.DarkRed,
                2,
                6);

            int nRet = 0;

            List<IXLCell> cells = new List<IXLCell>();

            // 栏目标题
            {
                List<string> titles = new List<string>();
                titles.Add("序号");
                titles.Add("册条码号");
                titles.Add("书目摘要");
                titles.Add("说明");
                titles.Add("金额");
                titles.Add("ID");

#if NO
                titles.Add("以停代金情况");
                titles.Add("起点日期");
                titles.Add("期限");
                titles.Add("终点日期");
#endif

                int nColIndex = 2;
                foreach (string s in titles)
                {
                    IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
                    cell.Style.Alignment.WrapText = true;
                    cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                    cell.Style.Font.Bold = true;
                    cell.Style.Font.FontColor = XLColor.DarkGray;
                    nColIndex++;
                    cells.Add(cell);
                }
                nRowIndex++;
            }

            int nItemIndex = 0;
            foreach (XmlElement borrow in nodes)
            {
                string strItemBarcode = borrow.GetAttribute("barcode");
                string strReason = borrow.GetAttribute("reason");
                string strPrice = borrow.GetAttribute("price");
                string strID = borrow.GetAttribute("id");
                string strRecPath = borrow.GetAttribute("recPath");

                string strSummary = borrow.GetAttribute("summary");
                if (string.IsNullOrEmpty(strItemBarcode) == false
                    && string.IsNullOrEmpty(strSummary) == true)
                {
                    string strError = "";
                    nRet = this.MainForm.GetBiblioSummary(strItemBarcode,
                        strRecPath, // strConfirmItemRecPath,
                        false,
                        out strSummary,
                        out strError);
                    if (nRet == -1)
                        strSummary = strError;
                }

                List<string> cols = new List<string>();
                cols.Add((nItemIndex + 1).ToString());
                cols.Add(strItemBarcode);
                cols.Add(strSummary);
                cols.Add(strReason);
                cols.Add(strPrice);
                cols.Add(strID);

                int nColIndex = 2;
                foreach (string s in cols)
                {
                    // 统计最大字符数
                    SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(s));

                    IXLCell cell = null;
                    if (nColIndex == 2)
                    {
                        cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
                        cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                    }
                    else
                        cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
                    cell.Style.Alignment.WrapText = true;
                    cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                    nColIndex++;
                    cells.Add(cell);
                }

                nItemIndex++;
                nRowIndex++;
            }

            // 标题行下的虚线
            var rngData = sheet.Range(cells[0], cells[cells.Count - 1]);
            rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Dotted;

            sheet.Rows(nStartRow + 1, nRowIndex - 1).Group();
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ReaderSearchForm.cs

示例4: OutputBorrows


//.........这里部分代码省略.........
                titles.Add("借期");
                titles.Add("应还时间");
                titles.Add("是否超期");

                int nColIndex = 2;
                foreach (string s in titles)
                {
                    IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
                    cell.Style.Alignment.WrapText = true;
                    cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                    cell.Style.Font.Bold = true;
                    cell.Style.Font.FontColor = XLColor.DarkGray;
                    //cell.Style.Font.FontName = strFontName;
                    //cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
                    nColIndex++;
                    cells.Add(cell);
                }
                nRowIndex++;
            }

            int nItemIndex = 0;
            foreach (XmlElement borrow in nodes)
            {
                string strItemBarcode = borrow.GetAttribute("barcode");
                string strBorrowDate = ToLocalTime(borrow.GetAttribute("borrowDate"), "yyyy-MM-dd HH:mm");
                string strBorrowPeriod = GetDisplayTimePeriodString(borrow.GetAttribute("borrowPeriod"));
                string strReturningDate = ToLocalTime(borrow.GetAttribute("returningDate"), "yyyy-MM-dd");
                string strRecPath = borrow.GetAttribute("recPath");
                string strIsOverdue = borrow.GetAttribute("isOverdue");
                bool bIsOverdue = DomUtil.IsBooleanTrue(strIsOverdue, false);
                string strOverdueInfo = borrow.GetAttribute("overdueInfo1");

                string strSummary = borrow.GetAttribute("summary");
#if NO
                            nRet = this.MainForm.GetBiblioSummary(strItemBarcode,
                                strRecPath, // strConfirmItemRecPath,
                                false,
                                out strSummary,
                                out strError);
                            if (nRet == -1)
                                strSummary = strError;
#endif

                List<string> cols = new List<string>();
                cols.Add((nItemIndex + 1).ToString());
                cols.Add(strItemBarcode);
                cols.Add(strSummary);
                cols.Add(strBorrowDate);
                cols.Add(strBorrowPeriod);
                cols.Add(strReturningDate);
                if (bIsOverdue)
                    cols.Add(strOverdueInfo);
                else
                    cols.Add("");

                int nColIndex = 2;
                foreach (string s in cols)
                {
                    // 统计最大字符数
                    SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(s));

                    IXLCell cell = null;
                    if (nColIndex == 2)
                    {
                        cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
                        cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                    }
                    else
                        cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
                    cell.Style.Alignment.WrapText = true;
                    cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                    //cell.Style.Font.FontName = strFontName;
                    //cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
                    nColIndex++;
                    cells.Add(cell);

                }

                // 超期的行为黄色背景
                if (bIsOverdue)
                {
                    var line = sheet.Range(nRowIndex, 2, nRowIndex, 2 + cols.Count - 1);
                    line.Style.Fill.BackgroundColor = XLColor.Yellow;
                }

                nItemIndex++;
                nRowIndex++;
            }

            // 册信息标题下的虚线
            var rngData = sheet.Range(cells[0], cells[cells.Count - 1]);
            rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Dotted;

#if NO
            // 第一行上面的横线
            rngData = sheet.Range(cell_no, cells[cells.Count - 1]);
            rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Medium;
#endif
            sheet.Rows(nStartRow + 1, nRowIndex-1).Group();
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ReaderSearchForm.cs

示例5: OutputBorrowHistory


//.........这里部分代码省略.........
                ChargingItem item = wrapper.Item;
                ChargingItem rel = wrapper.RelatedItem;

                string strItemBarcode = item.ItemBarcode;
                string strBorrowDate = rel == null ? "" : rel.OperTime;
                string strBorrowPeriod = GetDisplayTimePeriodString(rel == null ? "" : rel.Period);
                string strReturnDate = item.OperTime;
                //string strRecPath = borrow.GetAttribute("recPath");
                //string strIsOverdue = borrow.GetAttribute("isOverdue");
                //bool bIsOverdue = DomUtil.IsBooleanTrue(strIsOverdue, false);
                //string strOverdueInfo = borrow.GetAttribute("overdueInfo1");

                string strSummary = "";
#if NO
                if (string.IsNullOrEmpty(strItemBarcode) == false
                    && string.IsNullOrEmpty(strSummary) == true)
                {
                    string strError = "";
                    int nRet = procGetBiblioSummary(strItemBarcode,
                        "", // strConfirmItemRecPath,
                        false,
                        out strSummary,
                        out strError);
                    if (nRet == -1)
                        strSummary = strError;
                }
#endif
                item_barcodes.Add("@itemBarcode:" + strItemBarcode);

                List<string> cols = new List<string>();
                cols.Add((nItemIndex + 1).ToString());
                cols.Add(strItemBarcode);
                cols.Add(strSummary);

                cols.Add(strBorrowDate);
                cols.Add(strBorrowPeriod);
                cols.Add(rel == null ? "" : rel.Operator);

                cols.Add(strReturnDate);
                cols.Add(item.Operator);

                int nColIndex = 2;
                points.Add(new Point(nColIndex + 2, nRowIndex));
                foreach (string s in cols)
                {
                    // 统计最大字符数
                    SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(s));

                    IXLCell cell = null;
                    if (nColIndex == 2)
                    {
                        cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
                        cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                    }
                    else
                        cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
                    cell.Style.Alignment.WrapText = true;
                    cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                    //cell.Style.Font.FontName = strFontName;
                    //cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
                    nColIndex++;
                    cells.Add(cell);
                }

#if NO
                // 超期的行为黄色背景
                if (bIsOverdue)
                {
                    var line = sheet.Range(nRowIndex, 2, nRowIndex, 2 + cols.Count - 1);
                    line.Style.Fill.BackgroundColor = XLColor.Yellow;
                }
#endif

                nItemIndex++;
                nRowIndex++;
            }

            // 加入书目摘要
            summary_loader.RecPaths = item_barcodes;
            int i = 0;
            foreach (BiblioItem biblio in summary_loader)
            {
                Point point = points[i];
                int nColIndex = point.X;
                // 统计最大字符数
                SetMaxChars(ref column_max_chars, nColIndex - 1, GetCharWidth(biblio.Content));

                IXLCell cell = null;
                cell = sheet.Cell(point.Y, nColIndex).SetValue(biblio.Content);
                cell.Style.Alignment.WrapText = true;
                cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                i++;
            }

            // 册信息标题下的虚线
            var rngData = sheet.Range(cells[0], cells[cells.Count - 1]);
            rngData.FirstRow().Style.Border.TopBorder = XLBorderStyleValues.Dotted;

            sheet.Rows(nStartRow + 1, nRowIndex - 1).Group();
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:ReaderSearchForm.cs

示例6: CreateAWorkSheet

        /// <summary>
        /// Create a worksheet
        /// </summary>
        /// <param name="worksheet">IXLWorksheet</param>
        /// <param name="sheet">CExcelSheet</param>
        private void CreateAWorkSheet(IXLWorksheet worksheet, CExcelSheet sheet)
        {
            //title
            IXLAddress firstAdd = worksheet.Cell(1, COL_BEGIN).Address;
            worksheet.Cell(1, 1).Value = sheet.Title;
            worksheet.Cell(1, 1).Style.Font.Bold = true;
            worksheet.Cell(1, 1).Style.Font.FontSize = 15;
            worksheet.Cell(1, 1).Style.Font.FontColor = XLColor.White;
            worksheet.Cell(1, 1).Style.Fill.BackgroundColor = XLColor.FromArgb(0x0066cc);

            #region Export By

            int rowIdx = ROW_BEGIN;
            if (sheet.ExportBy != null)
            {
                foreach (var item in sheet.ExportBy)
                {
                    // reset column
                    int colIdx = COL_BEGIN;

                    worksheet.Cell(rowIdx, colIdx).DataType = XLCellValues.Text;
                    worksheet.Cell(rowIdx, colIdx).Value = "'" + item.key;
                    worksheet.Range(
                        worksheet.Cell(rowIdx, colIdx).Address,
                        worksheet.Cell(rowIdx, colIdx + 2).Address).Merge();
                    colIdx += 3;
                    worksheet.Cell(rowIdx, colIdx).DataType = XLCellValues.Text;
                    worksheet.Cell(rowIdx, colIdx).Value = "'" + item.value;
                    // new row
                    rowIdx++;
                }
            }

            #endregion

            // Header
            int col = COL_BEGIN;

            #region Header
            //Add No
            if (sheet.IsRenderNo)
            {
                worksheet.Cell(rowIdx, col).Value = "No";
                worksheet.Cell(rowIdx, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                worksheet.Cell(rowIdx, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                col++;
            }
            foreach (string header in sheet.Header)
            {
                worksheet.Cell(rowIdx, col).Value = header;
                worksheet.Cell(rowIdx, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                col++;
            }
            //Style for header
            worksheet.Range(worksheet.Cell(rowIdx, COL_BEGIN).Address, worksheet.Cell(rowIdx, col - 1).Address).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            worksheet.Range(worksheet.Cell(rowIdx, COL_BEGIN).Address, worksheet.Cell(rowIdx, col - 1).Address).Style.Font.Bold = true;
            worksheet.Range(worksheet.Cell(rowIdx, COL_BEGIN).Address, worksheet.Cell(rowIdx, col - 1).Address).Style.Font.FontSize = 12;
            worksheet.Range(worksheet.Cell(rowIdx, COL_BEGIN).Address, worksheet.Cell(rowIdx, col - 1).Address).Style.Fill.BackgroundColor = XLColor.FromTheme(XLThemeColor.Accent1, 0.5);
            //merge title
            IXLAddress secondAdd = worksheet.Cell(1, col - 1).Address;
            worksheet.Range(firstAdd, secondAdd).Merge();
            worksheet.Range(firstAdd, secondAdd).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            // Merge export by
            for (int i = ROW_BEGIN; i < rowIdx; i++)
            {
                worksheet.Range(
                    worksheet.Cell(i, 4).Address,
                    worksheet.Cell(i, col - 1).Address).Merge();
            }
            #endregion

            // detail
            // Comment when adding export by, rowIdx is the number of export by
            //int idx_row = ROW_BEGIN + 1;
            int idx_row = rowIdx + 1;
            string preGroup = string.Empty;
            ArrayList beginSubList = new ArrayList();
            ArrayList endSubList = new ArrayList();
            //linh.quang.le: Freeze panels
            worksheet.SheetView.FreezeRows(sheet.FreezeRow);
            worksheet.SheetView.FreezeColumns(sheet.FreezeColumn);
            //linh.quang.le number
            int no = 1;

            #region Detail
            foreach (Object row in sheet.List)
            {
                int idx_col = COL_BEGIN;
                int index = 0;
                bool hasMainColumnValue = HasMainColumnValue(row, sheet);
                //linh.quang.le
                #region GroupName
                if (sheet.IsGroup)
                {
                    string groupName = string.Empty;
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:lg-py,代码行数:101,代码来源:ExportExcelAdvance.cs


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