0

Please help me. I have a question for npoi c#

Generally to set value in npoi is

sheet = workbook.GetSheetAt(0);
IRow row = sheet.GetRow(0);
ICell cell = rowA.GetCell(0);
cell.setvalue("Sometime");

but, Can I set value by cell name from excel? example

at cell A1 set name to salary

and code like this

    row = sheet.GetRow(0);
    cell = row.getID(A1/salary); //get A1 or salary
    cell.setvalue(5000); // result in cell A1 = 5000

thank you.

pawaqma
  • 21
  • 3

1 Answers1

1

You can't get cell by name only by the reference with using CellReference.

var sheet = workbook.GetSheetAt(0);
var cr = new CellReference("A1");
var row = sheet.GetRow(cr.Row);
var cell = row.GetCell(cr.Col);
cell.setvalue(5000);
user2250152
  • 14,658
  • 4
  • 33
  • 57