how to use worksheet.Cells.PutValue for % values because if i insert 30 using worksheet.Cells.PutValue am getting out as 3000%
Hi,
Please see the code below to insert values in a percentages.
Please download and use the the latest version:
Aspose.Cells
for .NET v7.0.4.5
I have attached the output xlsx file and the screenshot.
C#
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cell cell = worksheet.Cells[“A1”];
cell.PutValue(30);
Style style = cell.GetStyle();
style.Number = 10; //For percentage.
cell.SetStyle(style);
workbook.Save(@“F:\Shak-Data-RW\Downloads\output.xlsx”);
Hi,
Well, the percentage values will be based on the source values of the cells. For example 10%--> refers to =10/100 = 0.1. So, you will insert 30/100 (e.g cell.PutValue(.3)) for your needs to get your desired percentage value. This behavior is same as MS Excel you may check it, e.g Insert 30 in a cell, then right click on the cell and click "Format Cells...", now click "Percentage" option in the first tab of "Format Cells " dialog box, you will see "3000.00%" by default.
Thank you.
HI
Is there is any replacement for doc.range.replace in excel.ie is i need use similar kind of code for excel
Hi,
I think you may try to rewrite the cells value in the way:
e.g
cell.PutValue(cell.IntValue/100);
Thank you.