ExcelIO open() losing property in mapping

Posted by: david.paradis on 21 January 2022, 8:47 am EST

  • Posted 21 January 2022, 8:47 am EST

    Hello,

    We are overriding some methods of spreadjs and one strange issue seems to come back on differents scenarios, but they all point to one thing, when we initially load a excel file with ExcelIO.Open. The excel is received from a c# web api. When we import directly with spreadJS the same excel file, the problem is not present. Maybe there is an error in the mappings of some properties with ExcelIO?

    Example, after loading, if there's a background color, if we change a format setting, example set bold, the color just dissapear from the interface (the cell background become white). In the SetStyle function, we receive backColor: "". (maybe here is an issue too, why is backColor not undefined if it was not modified)

    Other thing, i don't know if this is connected with this problem. If you stay in the sheet and change multiple style, calling SetStyle multiple time, every new SetStyle the cell style state is passed as a value, with every property we modified in the cell before: color, alignment, border, etc... But if we load the excel, if a cell contains some style, the first time SetStyle is called, every property that was set before (color, border, bold, italic, etc....) is lost and not send in the SetStyle method, only the parameter associated to the operation we just did, example set verticalAlign to 1. Is this normal?

    Take this cell:


    If i remove the italic, the value of the SetStyle is:


    And it now looks like:



    Thanks!
  • Replied 23 January 2022, 11:39 pm EST

    Hi,

    We are unable to replicate the issue at our end. Could you please share a sample describing the steps you have performed so that we can investigate at our end once.

    Regards.
  • Replied 25 January 2022, 2:56 am EST

    Hello,

    What is the expected behavior when setStyle is called?

    1- Only the new value set on the cell is send

    2- The complete style of the cell is send

    Thanks
  • Replied 25 January 2022, 7:44 am EST

    Here is a sample,
    demo.zip

    The first cell (0, 0) have some style applied. Make sure to open the console and click the top left button getStyle, the result is like :


    Then if you change a style, example here i set the font to bold, then i click again the getStyle button i get:
  • Replied 26 January 2022, 11:19 pm EST

    Hi,

    I was unable to replicate the issue at my end as I couldn't find the excel file in the sample that you sent. However, I have tested with another excel file(test2.xlsx) and still was unable to replicate the issue
    getStyle() returns the style set using the setStyle() method. Designer uses setStyle() method to set the styles on sheet(e.g. font, underline).
    To get the actual style information for a specified cell in the specified sheet area, you should use the getActualStyle method: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~getActualStyle.html
    We request you to share the excel file that you have used so that we could investigate further and assist you accordingly.
    Please refer to the attached gif. The second object in the console is retrieved using getActualStyle method.



    Regards,
    Avinash
  • Replied 27 January 2022, 1:06 am EST

    test2.zip

    Oups, here is the Excel file!

    I will try the getActualStyle.

    We kinda "expected" the setStyle/getStyle to send all the properties but if it is the expected behavior we will work with it!

    Thanks
  • Replied 27 January 2022, 5:53 pm EST

    Hi,

    We are still unable to replicate the issue with the Excel file you shared with us. Please have a look at the attached gif and let us know if we are missing any step(s).
    As mentioned earlier, to get the actual style information for a specified cell in the specified sheet area, you should use the getActualStyle method:

    https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~getActualStyle.html

    Try getting all the style properties using getActualStyle method and let us know if you face any issues further

    Regards,
    Avinash

  • Replied 28 January 2022, 8:24 am EST


    In your video you can see after the first click the hAlign is set to 1, later it is set to undefined.

    Maybe try with only 1 or 2 style, like the border and you'll see the other property dissapear.

    You can ignore the first issue with the background color dissapearing this is an issue on our side, generated by the fact we assumed the full actual style was passed in the setStyle method.

    In our setStyle override method we use the getActualStyle value instead of the original value passed to setStyle and it seems to work that way.

    Thanks
  • Marked as Answer

    Replied 31 January 2022, 3:18 pm EST

    Hi,

    We are glad that the issue has been resolved.
    When setStyle() method is called, it sets the style information(only the style properties defined) for a specified cell in the specified sheet area. Only the new style properties are set. When you call the getStyle() method, it return you the last properties set using setStyle() method and all the other properties are undefined.
    getActualStyle() returns the cell's inherited style.

    Regards.
Need extra support?

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

Learn More

Forum Channels