Bug Report T303329
Visible to All Users

The Range.Value property setter affects a cell's NumericFormat

created 9 years ago

A format is set to a cell like : ,
If we set value directly like : mmmm-yyworksheet.Cells["B5"].Value = new DateTime(2015, 12, 25, 00, 00, 00); => OK

if we set value through Offset like
      worksheet.Cells["B4"].Offset(1, 0).Value = new DateTime(2015, 12, 25, 00, 00, 00); => NumberFormat is lost and reset

Best regards

Alexandre

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

    created 9 years ago

    Hi,

    Please note that the Offset method returns a range instead of a certain cell and the Range.Value property is not the same as the Cell.Value property. If set the Range.Value property to the DateTime value then the NumericFormat of this cell is changed to the current culture's default DateTime format. I suggest you use the following code to set Range.Value property so its NumericFormat is not changed:

    C#
    worksheet.Cells["B4"].Offset(1, 0).Value = CellValue.FromDateTime(new DateTime(2015, 12, 25, 00, 00, 00), false).NumericValue;

    If you need further assistance, let me know.

      Comments (2)
      AR AR
      Alexandre Richonnier 9 years ago

        Hi George,
        I'm not agree with you. Cell inherit from Range.
        worksheet.Cells["B5"].Value is a
        public abstract CellValue Value { get; set; }
        in class Range
        An produce no problem.
        worksheet.Cells["B4"].Offset(1, 0).Value is a:
        public abstract CellValue Value { get; set; }
        in class Range
        And produce the problem.
        And this problem is not limited to Date, number format is impacted too.
        To Finish, if offset function api have some side effect, it is not very good. In both situation we get a CellValue… How could we know? set a value, doesn't impact format in a range or cell in Excel.
        Inheritance behaviour must not have side effect on any other property outside…
        And logically,  why on Range.Value, underlying Cell.Value is not call?
        Best regards,
        Alexandre

        DevExpress Support Team 9 years ago

          Hi,

          Please accept my apologies for misleading you.
          I have passed this ticket to our developers for further research.
          Please bear with us. We will notify you as soon as we make any progress.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.