This project has moved and is read-only. For the latest updates, please go here.

Date modification has a random last date

Dec 10, 2013 at 6:12 PM
Edited Dec 10, 2013 at 6:18 PM

Right now I am trying to read in a spreadsheet, modify its date column, then save it to a new location. I attempt to change the date to today plus one day. The code I'm using is as follows:
worksheet.Column(dateColumnIndex).Style.Numberformat.Format = @"d/m/yyyy";
for (var row = 2; row <= rowCount; row++)
    worksheet.SetValue(row, dateColumnIndex, DateTime.Now.Date.AddDays(1));
worksheet.Column(dateColumnIndex).Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
worksheet.Column(dateColumnIndex).Style.VerticalAlignment = ExcelVerticalAlignment.Top;
This works fine for the first rows. However, the last row for whatever reason always ends up as the 7th of the current month.

For example, if I were to run the code today, the date column would be set to 11/12/2013 for every row but the last, which would be set to 7/12/2013.

Does anyone have any ideas?

EDIT: D'oh, please ignore. My rowcount was starting from 1 while the loop began at 2 to avoid modifying the column header.