1
Vote

WeekDay Function Uses Monday=1 Instead of Sunday=1

description

Excel default weekday start is Sunday=1 but NPOI uses Date.DayOfWeek() which follows ISO with Monday=1.
The value displayed in excel hence is not the same as the value given by NPOI once the workbook is evaluated by NPOI.

you can reproduce using a workbook with a single value in first cell: '=WEEKDAY(TODAY())' and the following code
        Dim wb As IWorkbook = WorkbookFactory.Create(originalfilepath)
        Dim sh As ISheet = wb.GetSheetAt(0)
        Dim c As ICell = sh.GetRow(0).GetCell(0)
        Console.WriteLine(c.NumericCellValue)
        wb.GetCreationHelper().CreateFormulaEvaluator().EvaluateAll()
        Console.WriteLine(c.NumericCellValue)
        Console.ReadLine()
Output (29/06/2017):
5
4

comments