Date time format issue in excel cell

Add-in Express™ Support Service
That's what is more important than anything else

Date time format issue in excel cell
 
Jude Milstan




Posts: 15
Joined: 2014-04-03
[img]https://drive.google.com/open?id=1ybhTCQFLn5pJQ40w7tDXO5O74fgz8Mbs[/img]

Hi there,

I am using latest add in express set up/dll professional and excel 2016, attached image show that same column having 2 different date formats and therefore has different alignment, we are using the below coding to format data to cell before printing, i am not sure why the same column has different cells with 2 different formats, this is happening in client side only in my local machine or any of our QA/Developer machines this is cannot replicate,both instance the format is dd/mm/yyyy but one is DATE other is CUSTOM causing the issue.

Note: There is no logic implemented to change Cell format of the same column from our end.

public static void setCellValue(Excel.Range table, int row, int col, XmlNode node, string source)
{
...
...
cell.NumberFormat = "dd/mm/yyyy";
DateTime dateCol = getDate(node, columns[i]); //The we get the date value from our private function from an XML
cell.Value2 += dateCol.ToShortDateString();

Thanks.
Posted 07 Aug, 2018 09:40:17 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Jude,

The last line adds a string to the value existing in the cell. Is this correct? Maybe, you want to sum dates, not strings?


Andrei Smolin
Add-in Express Team Leader
Posted 07 Aug, 2018 10:20:15 Top
Jude Milstan




Posts: 15
Joined: 2014-04-03
Thanks for highlighting, did not question that as it was there form beginning, any way we always genera-rate new Sheet and print items in cell after clearing the existing sheets therefore the value is blank before printing.

I am not sure if a regional setting is effecting but still why one set of cell differ that the other in the same column since the logic always formats all the cells in the same column and this behavior is puzzling.


Thanks.
Posted 09 Aug, 2018 08:46:53 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Jude,

This may relate to Excel interpreting (or misinterpreting) some values as dates or strings. Anyway, please check whether the issue goes away if you change the last line to cell.Value2 += dateCol.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Aug, 2018 08:54:40 Top