problem reading percentage values

5 posts, 0 answers
  1. Innermedia
    Innermedia avatar
    3 posts
    Member since:
    Jan 2012

    Posted 31 Mar 2015 Link to this post

     I have been using radspreadsheet for reading .csv files for some time now.  I am now working on an application that requires me to read .xslx files.  The only issue I have is the following: When reading percentage values, if the values are too small, I get a zero returned for the cell value.  For example, if my spreadsheet is:

    0.10% 
    1.00%
    10.00%
    100.00%

    when reading the values, where the cell format is "percentage", I get the following values:
    0
    0.01
    0.1
    1

    On the spreadsheet, I have the number of decimal points set to 6.

            private string GetCellValue(Worksheet ws, int RowIndex, int ColumnIndex)
            {
                CellSelection cell;
                ICellValue value;
                string cellvalue = "0";
                cell = ws.Cells[RowIndex, ColumnIndex];
                value = cell.GetValue().Value;
                if (value != null) cellvalue = value.RawValue.ToString();












  2. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 03 Apr 2015 Link to this post

    Hi Brian,

    I have tested the scenario you have described. Using MS Excel I have created a workbook containing the following values using cell format "percentage" with two decimal places:

    0.10%
    1.00%
    10.00%
    100.00%

    I have imported it in RadSpreadProcessing and when I get the cell values the result is slightly different from yours:

    0.001 - here is the difference
    0.01
    0.1
    1

    Could you check if the first value which you get from the cell really is 0.

    This is expected behavior. Actually if you multiply the values by 100 you will get the entered percentage values. This behavior can be explained with the formula for calculating the percentage of a number. For example 10% of 40 is 40 * 10% = 40 * 10 / 100 = 40 * 0.1.

    If you want to get the formatted result value form the cell you could use the following code:
    value = cell.GetValue().Value;
    CellValueFormat format = cell.GetFormat().Value;
    if (value != null) cellvalue = value.GetResultValueAsString(format);


    Regards,
    Nikolay Demirev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. Innermedia
    Innermedia avatar
    3 posts
    Member since:
    Jan 2012

    Posted 03 Apr 2015 in reply to Nikolay Demirev Link to this post

    Thank you for your response.  I have done a little more investigation.

    My code for reading the cell values works correctly for .csv files, but it fails for .xlsx files. I am using version 2013.2.724.45 (Runtime version v4.0.30319).

    Yesterday, I downloaded the latest Telerik UI for WPF (demo) and rebuilt my application, and it worked perfectly for both csv and xlsx files.  

    My conclusion is that there is a bug in the version of the Telerik controls that I am using - probably in the OpenXML format provider or the Documents.Spreadsheet dll.

    Please advise, and thank you for your time.

  4. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 06 Apr 2015 Link to this post

    Hi Brian,

    I have tested if the issue really exists in version 2013.2.724.45 and was abe to reproduce it. The only solution I can provide is to update your binaries to the latest version. This way you will get all the new features, bug fixes and performance improvements introduced since Q2 2013 SP1.

    Is there any specific reason why you want to use the older version binaries?

    Regards,
    Nikolay Demirev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  5. Innermedia
    Innermedia avatar
    3 posts
    Member since:
    Jan 2012

    Posted 06 Apr 2015 in reply to Nikolay Demirev Link to this post

    Nikolay,

    Thank you for your response.  I am glad that you were able to reproduce the problem.

    To answer your question: No, there is no specific reason why we would need to use the older binaries.

    Brian

Back to Top