Ejemplo n.º 1
0
        // retrieve cell based on column and row index
        public Cell RetreiveCell(Worksheet worksheet,
                                 string columnName, uint rowIndex)
        {
            Row row    = RetrieveRow(worksheet, rowIndex);
            var newRow = new Row()
            {
                RowIndex = (uint)rowIndex + 1
            };

            //adding new row
            worksheet.InsertAt(newRow, Convert.ToInt32(rowIndex + 1));
            //create cell with value
            Cell cell = new Cell();

            cell.CellValue = new CellValue("");
            cell.DataType  =
                new EnumValue <CellValues>(CellValues.String);
            newRow.AddAnnotation(cell);
            worksheet.Save();

            row = newRow;
            if (row == null)
            {
                return(null);
            }
            return(row.Elements <Cell>().Where(c => string.Compare(c.CellReference.Value, columnName +
                                                                   (rowIndex + 1), true) == 0).First());
        }