public void TestNotCreateEmptyCells() { IWorkbook wb = new HSSFWorkbook(); Npoi.Core.SS.UserModel.ISheet sheet = new SheetBuilder(wb, testData).Build(); Assert.AreEqual(sheet.PhysicalNumberOfRows, 3); Npoi.Core.SS.UserModel.IRow firstRow = sheet.GetRow(0); Npoi.Core.SS.UserModel.ICell firstCell = firstRow.GetCell(0); Assert.AreEqual(firstCell.CellType, CellType.Numeric); Assert.AreEqual(1.0, firstCell.NumericCellValue, 0.00001); Npoi.Core.SS.UserModel.IRow secondRow = sheet.GetRow(1); Assert.IsNotNull(secondRow.GetCell(0)); Assert.IsNull(secondRow.GetCell(2)); Npoi.Core.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); }
/// <summary> /// Gets the row height in points. /// </summary> /// <param name="sheet">The sheet.</param> /// <param name="rowNum">The row num.</param> /// <returns></returns> private float GetRowHeightInPoints(Npoi.Core.SS.UserModel.ISheet sheet, int rowNum) { Npoi.Core.SS.UserModel.IRow row = sheet.GetRow(rowNum); if (row == null) { return(sheet.DefaultRowHeightInPoints); } else { return(row.HeightInPoints); } }