1

I want to apply this formula to all C3 cells excluding header '=IF(ISBLANK(B3), "", 10)' to my spreadsheet.

How can I achieve that?

2 Answers2

0

Try this:

var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sheet1");
var cell = worksheet.Cells["C3"];
cell.Formula = "'=IF(ISBLANK(B3), \"\", 10)";
workbook.Save("output.xlsx");
Mario Z
  • 4,328
  • 2
  • 24
  • 38
0

This is what I have finally come to:

     worksheet.Cells.GetSubrange("C2", "C5000").Formula = $@"=IF(ISBLANK(B2:B5000 ), """", {10})";
     
        worksheet.DataValidations.Add(new DataValidation(worksheet.Columns[5].Cells.GetSubrange("C2", "C5000"))
        {
            Type = DataValidationType.WholeNumber,

            Operator = DataValidationOperator.Equal,              
            InputMessageTitle = "Edits Not Allowed",
            InputMessage = "Value in the cell cannot be changed",
            ErrorTitle = "Edits Not Allowed",
            ErrorMessage = "Value in the cell cannot be changed"
        }); ;