public void CreateChangeSaveOpenReadWorks() { var location = new ExcelCellLocation("sheet1", 1, 3); var value = "asdas fsdl.ögkjd"; var readValue = string.Empty; IInMemoryFile excelFile = null; using (var context1 = new NpoiExcelContext()) { context1.OpenExcel(); context1.SetValue(location, value); excelFile = context1.WriteExcel("myExcel"); } using (var context2 = new NpoiExcelContext()) { context2.OpenExcel(excelFile); readValue = context2.GetValue(location); } readValue.Should().Be(value); excelFile.FileName.Should().Be("myExcel.xlsx"); }
public string GetValue(ExcelCellLocation cellLocation) { this.CheckWorkbook(); ISheet sheet = this.workbook.GetSheet(cellLocation.SheetName); if (sheet == null) { return(string.Empty); } IRow row = sheet.GetRow(cellLocation.CellIndex.Row); if (row == null) { return(string.Empty); } var cell = row.GetCell(cellLocation.CellIndex.Column, MissingCellPolicy.RETURN_BLANK_AS_NULL); if (cell == null) { return(string.Empty); } return(cell.StringCellValue); }
public void SetValue(ExcelCellLocation cellLocation, string value) { this.CheckWorkbook(); var cell = GetCellEnsured(cellLocation); cell.SetCellValue(value); }
public VisualElementContext(object model, ExcelCellLocation rootLocation) { this.Model = model; this.RootLocation = rootLocation; }
private ICell GetCellEnsured(ExcelCellLocation cellLocation) { return(this.GetCellEnsured(cellLocation.SheetName, cellLocation.CellIndex.Row, cellLocation.CellIndex.Column)); }