Groups | Blog | Home
all groups > c# > june 2005 >

c# : C# and Excel


Snoozer654
6/25/2005 7:51:01 PM
I'm trying to format a cell in Excel using the Excel Interop. Example: I need
to format a cell to be "610.00" Excel defaults this to 610. When I try to
match on this value of course I am not able to becasue of formating.

Later on I will need to format some dates but if I can get this one for now
I'll be happy. Then I might be able to figure out the date one on my own.

Thank You
--
shrewdmonkey
6/25/2005 8:51:01 PM
I don't know anything about interop but i'd suggest setting the cell
format using: cells(x,y).NumberFormat = "0.00" which only affects
appearance and then compare cell values using cells(x,y).Value...

Hope that's even remotely close to what you're lookin for :S
Snoozer654
6/26/2005 9:42:02 PM
Thank you. I'll give it a try.
--
Dopey


[quoted text, click to view]
Snoozer654
6/29/2005 6:08:01 AM
Thanks shrewdmonky. I worked on your proposed solution but was not able to
make it work. Thanks to a friend however I have the right syntax.

Which is:

Excel.Range columnToFormat = oSheet.get_Range("A1","A100");
columnToFormat.NumberFormat = "#,##0.00_);[Red] (#,##0.0)"

This works as expected. Why is it so hard for Microsoft to put out useful
documentation?
--
Dopey


[quoted text, click to view]
AddThis Social Bookmark Button