Excel column formatting issue, format style changed when formatted again with the same style
-
Hello, I am in the process of trying to fix this bug that has cropped up in some code I am maintaining. The issue is this: The application runs through some data from an excel spreadsheet and when it is finished, it formats and saves the spreadsheet before closing it out. This works, but heres the thing, when a spreadsheet is run through the app the first time, the columns are formatted correctly as Currency, but when the same spreadsheet is run again, the columns formatted as Currency are now formatted as Accounting for some reason even though the lines of code doing the formatting clearly state Currency like this:
objExcelSheet.Columns(eSheetLocations.AMT).Style = "Currency"
This is proving to be one heck of a noodle scratcher, as I have no clue why it is doing this. I had originally considered a workaround by trying to get the current style by having a variable set to it, but the variable returnsNothing
when I step through. The reason I need this to stay Currency is because zero-dollar amounts need to be seen as "$0.00" and not "-" as this confuses the end users. Any help and advice is welcome, thanks in advance. -
Hello, I am in the process of trying to fix this bug that has cropped up in some code I am maintaining. The issue is this: The application runs through some data from an excel spreadsheet and when it is finished, it formats and saves the spreadsheet before closing it out. This works, but heres the thing, when a spreadsheet is run through the app the first time, the columns are formatted correctly as Currency, but when the same spreadsheet is run again, the columns formatted as Currency are now formatted as Accounting for some reason even though the lines of code doing the formatting clearly state Currency like this:
objExcelSheet.Columns(eSheetLocations.AMT).Style = "Currency"
This is proving to be one heck of a noodle scratcher, as I have no clue why it is doing this. I had originally considered a workaround by trying to get the current style by having a variable set to it, but the variable returnsNothing
when I step through. The reason I need this to stay Currency is because zero-dollar amounts need to be seen as "$0.00" and not "-" as this confuses the end users. Any help and advice is welcome, thanks in advance.That is strange, but then again you should always expect surprises from MickeySoft. A simple work around would be to somehow flag the spreadsheet when you run it through the app, and checking for that flag first when you get to the style changing bit. Not flagged = set style, and flag Flagged = skip style setting, and leave the flag be.
My advice is free, and you may get what you paid for.