With this code:
totalPriceCell.Value2 = TotalPrice;
...I was getting values such as "3.14963245" which I want to be "3.15" instead.
So I used this code:
totalPriceCell.Value2 = TotalPrice.ToString("#.##");
...and that did solve that problem, but I still get values such as "7.6" and "35" (which I want to be "7.60" and "35.00")
What can I do to accomplish this, outside of manually appending a "0" for vals such as "7.6" and manually appending ".00" for values such as "35"?
UPDATE
Niether suggestion worked, neither this:
totalPriceCell.Value2 = TotalPrice.ToString("F2");
...nor this:
totalPriceCell.Value2 = Math.Round(TotalPrice, 2).ToString("F2");
I still get "7.6" etc.:
UPDATE 2
It turns out to be an Excel problem, because when I added this:
MessageBox.Show(Math.Round(TotalPrice, 2).ToString("F2"));
...I did see values such as "7.60" (not "7.6").