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


C# HSSFWorkbook.SetRepeatingRowsAndColumns方法代码示例

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


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

示例1: TestRepeatingRowsAndColumsNames

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

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

            Assert.AreEqual("Print_Titles", nr1.NameName);
            if (false)
            {
#if !HIDE_UNREACHABLE_CODE
                //     TODO - full column references not rendering properly, absolute markers not present either
                Assert.AreEqual("FirstSheet!$A:$A,FirstSheet!$1:$3", nr1.RefersToFormula);
#endif
            }
            else
            {
                Assert.AreEqual("FirstSheet!A:A,FirstSheet!$A$1:$IV$3", nr1.RefersToFormula);
            }

            // Save and re-open
            HSSFWorkbook nwb = HSSFTestDataSamples.WriteOutAndReadBack(wb);

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

            Assert.AreEqual("Print_Titles", nr1.NameName);
            Assert.AreEqual("FirstSheet!A:A,FirstSheet!$A$1:$IV$3", nr1.RefersToFormula);

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

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

            Assert.AreEqual("Print_Titles", nr2.NameName);
            Assert.AreEqual("SecondSheet!B:C,SecondSheet!$A$1:$IV$1", nr2.RefersToFormula);

            //if (false) {
            //    // In case you fancy Checking in excel, to ensure it
            //    //  won't complain about the file now
            //        File tempFile = File.CreateTempFile("POI-45126-", ".xls");
            //        FileOutputStream fout = new FileOutputStream(tempFile);
            //        nwb.Write(fout);
            //        fout.close();
            //        Console.WriteLine("check out " + tempFile.GetAbsolutePath());
            //}
        }
开发者ID:xoposhiy,项目名称:npoi,代码行数:59,代码来源:TestHSSFName.cs

示例2: TestSetRepeatingRowsAndColumns

 public void TestSetRepeatingRowsAndColumns()
 {
     // Test bug 29747
     HSSFWorkbook b = new HSSFWorkbook();
     b.CreateSheet();
     b.CreateSheet();
     b.CreateSheet();
     b.SetRepeatingRowsAndColumns(2, 0, 1, -1, -1);
     NameRecord nameRecord = b.Workbook.GetNameRecord(0);
     Assert.AreEqual(3, nameRecord.SheetNumber);
 }
开发者ID:xoposhiy,项目名称:npoi,代码行数:11,代码来源:TestHSSFWorkbook.cs

示例3: TestRepeatingColsRows

        public void TestRepeatingColsRows()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            NPOI.SS.UserModel.ISheet sheet = workbook.CreateSheet("Test Print Titles");

            IRow row = sheet.CreateRow(0);

            ICell cell = row.CreateCell(1);
            cell.SetCellValue(new HSSFRichTextString("hi"));


            workbook.SetRepeatingRowsAndColumns(0, 0, 1, 0, 0);

            string filepath = TempFile.GetTempFilePath("TestPrintTitles", ".xls");

            FileStream fileOut = new FileStream(filepath, FileMode.OpenOrCreate);
            workbook.Write(fileOut);
            fileOut.Close();

            Assert.IsTrue(File.Exists(filepath), "file exists");
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:21,代码来源:TestWorkbook.cs

示例4: TestRepeatingColsRowsMinusOne

        public void TestRepeatingColsRowsMinusOne()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Test Print Titles");

            IRow row = sheet.CreateRow(0);

            ICell cell = row.CreateCell(1);
            cell.SetCellValue(new HSSFRichTextString("hi"));


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

            FileInfo file = TempFile.CreateTempFile("testPrintTitlesA", ".xls");

            FileStream fileOut = new FileStream(file.FullName, FileMode.Create, FileAccess.ReadWrite);
            workbook.Write(fileOut);
            fileOut.Close();
            Assert.IsTrue(file.Exists, "file exists");
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:20,代码来源:TestWorkbook.cs


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