Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

microsoft.interop.excel Formatting cells

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.

like image 236
Jonny Avatar asked Sep 13 '11 12:09

Jonny


1 Answers

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);
like image 164
TMB Avatar answered Sep 27 '22 21:09

TMB