Resetting Spread to Designer Layout While Running

Posted by: brwood on 2 November 2017, 2:42 pm EST

    • Post Options:
    • Link

    Posted 2 November 2017, 2:42 pm EST

    Good afternoon.

    I have designed a spread using the Spread Designer. I applied the design to the spread and it looks great every time I start the program.

    My users interact with the spread in many ways that can leave the format completely different than how I designed it.

    When they’re done with one item and ready to move onto the next, how do I simply reset the grid to the original layout I created in the designer?

    Every way I’ve tried so far has returned it to a spread with no formatting.

    Please help.

    Thanks,

    Brian

  • Posted 3 November 2017, 9:30 am EST

    Hello,

    You can save the original Spread to xml or Excel and load it back whenever you want to get back to original state.

    Thanks,

    Deepak Sharma

  • Posted 8 November 2017, 10:03 am EST

    I need to re-load it in code while the program is running.

    I have been unable to find the correct property to do so. Can you provide an example?

    Thanks,

    Brian

  • Posted 9 November 2017, 10:16 am EST

    Hi Brian,

    At any point in your project you can use the code below to save the xml from Spread using the code below:

    
    string f; 
    f = "D:\\samples\\spread.xml"; 
    System.IO.FileStream s = new System.IO.FileStream(f, IO.FileMode.CreateNew, IO.FileAccess.ReadWrite); 
    fpSpread1.ActiveSheet.SaveXml(s); 
    s.Close();
    
    

    Now you can load this xml file back in your application whenever required using the code below:

    
    FarPoint.Win.Spread.Model.SpreadSerializer.OpenXml(fpSpread1, "D:\\samples\\spread.xml");
    
    

    I hope it clarifies the use of serialization.

    Thanks,

    Deepak Sharma

  • Posted 9 November 2017, 2:11 pm EST

    Deepak, This only serialized the values that were in the spreadsheet.

    I am more concerned about restoring the spreads appearance (formatting).

    Whenever I do a fpSpread1.reset, all of the formatting goes away, I want to be able to then restore the formatting that I see in the spread designer (in code).

  • Posted 10 November 2017, 2:56 am EST

    Hello,

    You do not need to call the Reset method. Follow the steps given by my above to save you SpreadSheet with design and data and then load it back whenever required.

    In case saving to XML does not suit you, you can save to Excel and load it back.

    Thanks,

    Deepak Sharma

Need extra support?

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

Learn More

Forum Channels