This project has moved. For the latest updates, please go here.

Issue with numberformatID

Mar 16, 2011 at 4:18 PM

Hello MDeLeon,

I want to show 20% as a number in excel so i used the code like this

ws.Cell(row, col).Value = 20;            

ws.Cell(row, col).Style.NumberFormat.NumberFormatId = 9;

but in excel file it gives me 2000%. what should i do to get just 20% as number?

 

I am using the latest build for .net 4.0

Thanks & Regards

Prasun 

Coordinator
Mar 16, 2011 at 4:33 PM

cell.Value = 0.2;
cell.Style.NumberFormat.NumberFormatId = 9;

Mar 17, 2011 at 4:40 AM

Thanks for the reply.. ultimately this is what i did, i divided the number by 100 before i copy it to excel but

Is there a reason why NumberFormatID=9 multiplys the value with 100?

and also can you give a rough ETA on support for graphs and charts?

Your efforts are greatly appreciated

Thanks & Regards

Prasun 

Coordinator
Mar 17, 2011 at 4:57 AM

That's because a percentage is a way of expressing a number as a fraction of 100. You'll get the same behavior in Excel if you put the number 20 in a cell and then format it as a percentage; you'll get 2000%.

Mar 17, 2011 at 5:00 AM

Ok.. thanks for that