C1Excel: "XLCell.SetValue" crashes on NULL value

Posted by: wknauf on 15 October 2021, 8:14 am EST

    • Post Options:
    • Link

    Posted 15 October 2021, 8:14 am EST

    This was introduced in .520: the following line of code crashes because the value is NULL, see attached sample:

    
    sheet.GetCell(1, 1).SetValue(null, style);
    
    

    C1ExcelNullValue.zip

    This is caused by this code in “XLCell.SetValue”:

    
        public void SetValue(object value, XLStyle style)
        {
          if (style != null && value.ToString().StartsWith("'"))
          {
            ...
          }
    
    

    Workaround: use this code:

    
    sheet.GetCell(1, 1).Value = null;
    sheet.GetCell(1, 1).Style = style;
    
    

    Best regards

    Wolfgang

  • Posted 15 October 2021, 8:17 am EST

    By the way: the XML doc for this method does not mention this newly introduced behavior to set “QuotePrefix” and clip the quote from the value.

  • Posted 18 October 2021, 2:37 am EST

    Hi Wolfgang,

    We have reported this to the development team and will let you know when we have an update. We have also forwarded your feedback about the XML doc to the team and will get it addressed.

    [Internal Tracking ID : C1WIN-25897]

    Regards.

    Avnish

  • Posted 10 December 2021, 7:17 am EST

    Hi,

    The issue has been fixed in the latest 21v3 release, no exception is thrown when setting null using SetValue() method.

    Regards

    Avnish

  • Posted 10 December 2021, 11:49 am EST

    Thanks!

    Wolfgang

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels