I want to apply this formula to all C3 cells excluding header '=IF(ISBLANK(B3), "", 10)' to my spreadsheet.
How can I achieve that?
I want to apply this formula to all C3 cells excluding header '=IF(ISBLANK(B3), "", 10)' to my spreadsheet.
How can I achieve that?
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");
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"
}); ;