Pasting from a different instance of FarPoint Spread

Posted by: docrog on 8 September 2017, 3:14 pm EST

  • Posted 8 September 2017, 3:14 pm EST

    I have an MDI application which uses Farpoint.Spread 6.0.2003.2008.
    This can have multiple forms open, each with its own instance of Spread.

    If I try to copy a range of cells from one form to another then the formatting is incorrect.

    What appears to be happening is that the formatting in cells is based on implicitly Named Styles , and that these style names have different definitions in each instance of Spread.

    When the cells are pasted they are formatted based on the style with the same name in the destination sheet, even though this is different from the source sheet.

    Is there anyway to avoid this?

    note that pasting cells within the same instance of Spread works fine.
  • Replied 8 September 2017, 3:14 pm EST


    Yes, the behavior you are observing is by default. When the formatting of a cell is changed in Excel and the same file is loaded in Spread, it assigns a default style to the cell itself. We would try narrowing down this issue internally. However, could you please let us know if you are facing any problem due to the same? It would be really helpful if you can share your usecase so that we can assist you further accordingly.

    Thanks and Regards,
    Pragati Kaushik
  • Replied 8 September 2017, 3:14 pm EST


    Our usecase

    We have a program for preparing quotations. The program is single instance on a machine, but can have multiple quotes open.
    Quotes are persisted in Excel format, and have been migrated to Spread from the VB6 ActiveX Formula1 component.

    The user is free to format individual cells, though not using Named Styles.

    The user may wish to copy data and formatting from one quotation to another.

    With regards to the original question, I am now intercepting the clipboard data object, and extracting the named styles within it. I am modifying the name (so that it doesn't clash with the destination Spread instance) and adding the new name to the destination Spread's NamedStyle collection. I am also recording the cells that are associated with the style.
    Before pasting the values and formulas, I am running through each cell and setting its named style.

    This is working reasonably well.
    However, I seem to have to paste the Values first, then paste the Formulas separately in two operations.
    Is it possible to combine these enum values so that I can paste both formulas and values at the same time ( but not formatting)?
  • Replied 8 September 2017, 3:14 pm EST


    You may set ClipBoardPasteOptions to "All". It will paste all the formatting and formulas.

    Deepak Sharma
  • Replied 8 September 2017, 3:14 pm EST


    The behavior you are experiencing at the moment is by design. Please note, Spread works with different models. When a CellRange with a NamedStyle is copied from one Spread to another, only data from the original data model is copied. Since the NamedStyle belongs to the Style model, it does not get copied. However, if you try and set the BackColor of a cell range in spread directly without using a NamedStyle and then copy this cell range in a new Spread, the correct data with the expected BackColor is copied as the data and the formatting belongs to the same data model.

    In order to achieve your requirements, you would need to store the NamedStyle applied on the CellRange (to be copied) globally and then apply it to the new CellRange once the user copies the range from the first Spread.

    Hope it clarifies.

    Thanks and Regards,
    Pragati Kaushik
  • Replied 8 September 2017, 3:14 pm EST

    Thanks for the reply. That was useful
    My next issue is why do I get the named styles created. I didn't do so explicitly.
    The Spread workbook is being saved as Excel format. When it is reopened these stylenames have been applied.
    As an example, if I modified the saved file directly in Excel, changing the backcolor of a cell to Yellow, then reopen the file in Spread, then it appears that the cell has acquired a StyleName when it has been reopened. Typical StyleNames are "x-1-64".
  • Replied 8 September 2017, 3:14 pm EST


    <font color="#0085e4">Is it possible to combine these enum values so that I can paste both formulas and values at the same time ( but not formatting)?</font>

    No, the ClipboardPasteOptions is not a Flags enum so you can't combine options.

    I'm really sorry for the inconvenience; I'm working on finding a better solution for this use case. At this point, I think your solution is the only way to make it work correctly.

  • Marked as Answer

    Replied 8 September 2017, 3:14 pm EST

    Hi Sean,

    That was the conclusion that I had come to. While the code appears to be working now the performance isn't great and we are getting customer complaints regarding that, so any suggestions would be appreciated.


Need extra support?

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

Learn More

Forum Channels