Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am building a report using the microsoft.interop.excel library in C#.

I have something like this:

 Range rangeTarget;
 .
 .
 .
 rangeTarget = worksheet.get_Range("C" + row, "N" + row);

I want the range to display its values as whole numbers i.e. with no decimal places. I've tried rangeTarge.AutoFormat, but have no idea how to use it.

Any Ideas ?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
273 views
Welcome To Ask or Share your Answers For Others

1 Answer

I don't know what the other formats are but you can look on the MSDN.

Excel.Range ThisRange = ThisSheet.get_Range("A:A",system.type.missing);
ThisRange.NumberFormat = "0.00%";
ThisRange.NumberFormat = "General";    
ThisRange.NumberFormat = "hh:mm:ss";
ThisRange.NumberFormat = "DD/MM/YYYY";

Marshal.FinalReleaseComObject(ThisRange);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...