Just wondering if you have any idea why the bot is writing the datatable to an excel file using “write range” function, some of the date is written in US format and som date are in local format. Particularly for the date from 12 of the month.
I have checked the format cell of the input file while reading the data out and it seems to be the correct format.
I tried to print out the datatable and the date seems to be correct. Not sure why it happens when datatable is written back to excel with the “write range” function. Also, only happen if the date is from 12 and before.
Can you share the sample excel file?
If not
Try to debug it and look at the value of DT in immediate panel.
You can use the code I mentioned in the post above to convert the date format.
Hi Ryan!
Did you check written excel file ? formats of written cells are consistency ?
If you can’t find any problem , then can use ‘invoke vba’ activity
‘invoke vba’ should be used in excel application scope.
vba file extension: ~.vba
Sub Main()
Range(“A1:A30”).HorizontalAlignment = xlRight
End Sub
inputDT.AsEnumerable.ToList().ForEach(
Sub (row)
row("Date") = Date.ParseExact(row("Date").ToString, "dd/MM/yyyy", Globalization.CultureInfo.InvariantCulture).ToString.Split().First
End Sub)
Use Excel Applicaiton Scope for writing the excel file.
Hope it solves your problem
Please change the column name according to your input file. In my input file the date column name is ‘Date’
Result is still the same as the original issue.
Im thinking of using Write range with the scope to trigger other fields in excel file and use Write range workbook again to write the correct format.
I don’t feel it’s right though just don’t get the issue.
Did you use Excel Application Scope to Write The output excel file?
If No, Please use Excel Application Scope and write range to write the excel file after invoke code.