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


C# XSSFWorkbook.SetRepeatingRowsAndColumns方法代码示例

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


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

示例1: TestRepeatingRowsAndColums

        public void TestRepeatingRowsAndColums()
        {
            // First Test that Setting RR&C for same sheet more than once only Creates a
            // single  Print_Titles built-in record
            XSSFWorkbook wb = new XSSFWorkbook();
            wb.CreateSheet("First Sheet");

            wb.SetRepeatingRowsAndColumns(0, -1, -1, -1, -1);

            // Set repeating rows and columns twice for the first sheet
            for (int i = 0; i < 2; i++)
            {
                wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3);
                //sheet.CreateFreezePane(0, 3);
            }
            Assert.AreEqual(1, wb.NumberOfNames);
            IName nr1 = wb.GetNameAt(0);

            Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName);
            Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula);

            //remove the columns part
            wb.SetRepeatingRowsAndColumns(0, -1, -1, 0, 3);
            Assert.AreEqual("'First Sheet'!$1:$4", nr1.RefersToFormula);

            //revert
            wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3);

            //remove the rows part
            wb.SetRepeatingRowsAndColumns(0, 0, 0, -1, -1);
            Assert.AreEqual("'First Sheet'!$A:$A", nr1.RefersToFormula);

            //revert
            wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3);

            // Save and re-open
            IWorkbook nwb = XSSFTestDataSamples.WriteOutAndReadBack(wb);

            Assert.AreEqual(1, nwb.NumberOfNames);
            nr1 = nwb.GetNameAt(0);

            Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName);
            Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula);

            // check that Setting RR&C on a second sheet causes a new Print_Titles built-in
            // name to be Created
            nwb.CreateSheet("SecondSheet");
            nwb.SetRepeatingRowsAndColumns(1, 1, 2, 0, 0);

            Assert.AreEqual(2, nwb.NumberOfNames);
            IName nr2 = nwb.GetNameAt(1);

            Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr2.NameName);
            Assert.AreEqual("SecondSheet!$B:$C,SecondSheet!$1:$1", nr2.RefersToFormula);

            nwb.SetRepeatingRowsAndColumns(1, -1, -1, -1, -1);
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:57,代码来源:TestXSSFName.cs

示例2: Main

        static void Main(string[] args)
        {
            IWorkbook wb = new XSSFWorkbook();
            ISheet sheet1 = wb.CreateSheet("new sheet");
            ISheet sheet2 = wb.CreateSheet("second sheet");

            // Set the columns to repeat from column 0 to 2 on the first sheet
            IRow row1 = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue(1);
            row1.CreateCell(1).SetCellValue(2);
            row1.CreateCell(2).SetCellValue(3);
            IRow row2 = sheet1.CreateRow(1);
            row2.CreateCell(1).SetCellValue(4);
            row2.CreateCell(2).SetCellValue(5);


            IRow row3 = sheet2.CreateRow(1);
            row3.CreateCell(0).SetCellValue(2.1);
            row3.CreateCell(4).SetCellValue(2.2);
            row3.CreateCell(5).SetCellValue(2.3);
            IRow row4 = sheet2.CreateRow(2);
            row4.CreateCell(4).SetCellValue(2.4);
            row4.CreateCell(5).SetCellValue(2.5);

            // Set the columns to repeat from column 0 to 2 on the first sheet
            wb.SetRepeatingRowsAndColumns(0, 0, 2, -1, -1);
            // Set the the repeating rows and columns on the second sheet.
            wb.SetRepeatingRowsAndColumns(1, 4, 5, 1, 2);

            //set the print area for the first sheet
            wb.SetPrintArea(0, 1, 2, 0, 3);

            FileStream sw = File.Create("test.xlsx");
            wb.Write(sw);
            sw.Close();
        }
开发者ID:89sos98,项目名称:npoi,代码行数:36,代码来源:Program.cs

示例3: Test49253

        public void Test49253()
        {
            XSSFWorkbook wb1 = new XSSFWorkbook();
            XSSFWorkbook wb2 = new XSSFWorkbook();

            // No print Settings before repeating
            XSSFSheet s1 = wb1.CreateSheet() as XSSFSheet;
            Assert.AreEqual(false, s1.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageMargins());

            wb1.SetRepeatingRowsAndColumns(0, 2, 3, 1, 2);

            Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageMargins());

            XSSFPrintSetup ps1 = s1.PrintSetup as XSSFPrintSetup;
            Assert.AreEqual(false, ps1.ValidSettings);
            Assert.AreEqual(false, ps1.Landscape);


            // Had valid print Settings before repeating
            XSSFSheet s2 = wb2.CreateSheet() as XSSFSheet;
            XSSFPrintSetup ps2 = s2.PrintSetup as XSSFPrintSetup;
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageMargins());

            ps2.Landscape=(false);
            Assert.AreEqual(true, ps2.ValidSettings);
            Assert.AreEqual(false, ps2.Landscape);

            wb2.SetRepeatingRowsAndColumns(0, 2, 3, 1, 2);

            ps2 = s2.PrintSetup as XSSFPrintSetup;
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageMargins());
            Assert.AreEqual(true, ps2.ValidSettings);
            Assert.AreEqual(false, ps2.Landscape);
        }
开发者ID:WPG,项目名称:npoi,代码行数:38,代码来源:TestXSSFBugs.cs


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