I’m looking for a way to use uipath to change a cell’s format from general to number. I’m passing my values in as doubles but when I write them to excel, the values that should be showing up as 0 are showing as things like “-4.55E-13” and “1.36E-12”. When I manually change the cell format to “number” the values change to 0 but I need a way for my program to automatically change the cell formats for the values to show up correctly.
I’ve looked at all the other posts but can’t find something that I think would work for me. Any ideas??
It sounds silly, but try switching to the opposite of the write range activity you’re using. So if you’re currently using an Excel scope with the excel write range activity, try instead using the workbook write range and vice versa.
I was originally using write range inside of an excel scope so that I could create a new workbook to write the values to. I tried using the create file activity to create the new workbook before writing to it without excel scope but now I got the error “Archive file cannot be size 0”. Do you know how to get around this?
@caitlinscott - no need to use the create file activity. If you use the workbook write range and the file you specify doesn’t exist, it will create one for you
@Dave okay I got rid of the create file activity but unfortunately it didn’t fix the issue. It’s actually a bit worse to be honest - instead of just showing a number like “-4.55E-13” it’s showing numbers like “9.09494701772928E-13”
I made sure that every instance of the variable where I was manipulating it had been set to “convert.ToDouble(variable)” and this fixed a lot of the values that should’ve been zeros, but for some reason I still have some of them showing up with “4.55E-13”
Try using a decimal variable instead of double. If you’re dealing with monetary values, you should always be using a decimal anyways, but decimal provides more precision than a double variable
I don’t know if that would help because I feel like it would still be showing up as a very large decimal as opposed to 0 wouldn’t it?
I ended up adding an invoke vba activity to change the cell number format to “0.00” and it seemed to fix the issue! The values are all displaying as 0.00 now instead of the weird decimal things.