public void TestNotCreateEmptyCells() { IWorkbook wb = new HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet = new SheetBuilder(wb, testData).Build(); Assert.AreEqual(sheet.PhysicalNumberOfRows, 3); NPOI.SS.UserModel.IRow firstRow = sheet.GetRow(0); NPOI.SS.UserModel.ICell firstCell = firstRow.GetCell(0); Assert.AreEqual(firstCell.CellType, CellType.NUMERIC); Assert.AreEqual(1.0, firstCell.NumericCellValue, 0.00001); NPOI.SS.UserModel.IRow secondRow = sheet.GetRow(1); Assert.IsNotNull(secondRow.GetCell(0)); Assert.IsNull(secondRow.GetCell(2)); NPOI.SS.UserModel.IRow thirdRow = sheet.GetRow(2); Assert.AreEqual(CellType.STRING, thirdRow.GetCell(0).CellType); String cellValue = thirdRow.GetCell(0).StringCellValue; Assert.AreEqual(testData[2][0].ToString(), cellValue); Assert.AreEqual(CellType.FORMULA, thirdRow.GetCell(2).CellType); Assert.AreEqual("A1+B2", thirdRow.GetCell(2).CellFormula); }
public void TestEmptyCells() { NPOI.SS.UserModel.IWorkbook wb = new HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet = new SheetBuilder(wb, testData).SetCreateEmptyCells(true).Build(); NPOI.SS.UserModel.ICell emptyCell = sheet.GetRow(1).GetCell(1); Assert.IsNotNull(emptyCell); Assert.AreEqual(CellType.BLANK, emptyCell.CellType); }