Пример #1
0
        public void TestRemoveRow()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = workbook.CreateSheet("Test boolean");
            Row row = sheet.CreateRow(2);

            sheet.RemoveRow(row);
        }
Пример #2
0
        public void TestWriteModifySheetSimple()
        {
            string filepath = TempFile.GetTempFilePath("TestWriteSheetSimple",
                                                       ".xls");
            FileStream   out1 = new FileStream(filepath, FileMode.OpenOrCreate);
            HSSFWorkbook wb   = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet s = wb.CreateSheet();
            Row  r = null;
            Cell c = null;

            for (int rownum = 0; rownum < 100; rownum++)
            {
                r = s.CreateRow(rownum);

                for (int cellnum = 0; cellnum < 50; cellnum += 2)
                {
                    c = r.CreateCell(cellnum);
                    c.SetCellValue(rownum * 10000 + cellnum
                                   + (((double)rownum / 1000)
                                      + ((double)cellnum / 10000)));
                    c = r.CreateCell(cellnum + 1);
                    c.SetCellValue(new HSSFRichTextString("TEST"));
                }
            }
            for (int rownum = 0; rownum < 25; rownum++)
            {
                r = s.GetRow(rownum);
                s.RemoveRow(r);
            }
            for (int rownum = 75; rownum < 100; rownum++)
            {
                r = s.GetRow(rownum);
                s.RemoveRow(r);
            }
            wb.Write(out1);
            out1.Close();

            sanityChecker.CheckHSSFWorkbook(wb);
            Assert.AreEqual(74, s.LastRowNum, "LAST ROW == 74");
            Assert.AreEqual(25, s.FirstRowNum, "FIRST ROW == 25");
        }
Пример #3
0
        public void TestRemoveZeroRow()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = workbook.CreateSheet("Sheet1");
            Row row = sheet.CreateRow(0);

            try
            {
                sheet.RemoveRow(row);
            }
            catch (ArgumentException e)
            {
                if (e.Message.Equals("Invalid row number (-1) outside allowable range (0..65535)"))
                {
                    throw new AssertFailedException("Identified bug 45367");
                }
                throw e;
            }
        }