Problems with Sheet Cloning

Posted by: ashis on 8 September 2017, 1:25 pm EST

  • Posted 8 September 2017, 1:25 pm EST


    Hi Bob


    I am creating a new sheet of the current sheet and adding the sheet to the spread.


    But I found that after cloning , some rows which are not in the old sheet is getting added in the new sheet. For solving this, I am taking the data source of the current sheet and storing it in a data table and binding that data table after cloning to the new sheet.  Leave it it may be a bug in our code.


    But now  I am changing one field on Right click and setting a cell value for that row. After that if I am trying to clone a new sheet. At that time the new sheet has not reflecting the value I changed in last sheet on right click programatically.


    Is it a problem with Clone() or changing some thing programatically.


    Here the codes,..


    Please help..


     


    DataTable dtbOriginal = objFpSpread.Sheets[objFpSpread.ActiveSheetIndex].GetDataView(true).ToTable();


    FarPoint.Win.Spread.SheetView newSheet = objFpSpread.Sheets[objFpSpread.ActiveSheetIndex].Clone();


     


    int intOldSheetIndex = objFpSpread.ActiveSheetIndex;


    string strSrcScenroName = objFpSpread.Sheets[objFpSpread.ActiveSheetIndex].SheetName.ToString();


    // Set the Sheet Name


    newSheet.SheetName = "Ashsis ";


    newSheet.Tag = 0;

    objFpSpread.Sheets.Add(newSheet);


    //Assign original datatable to new Sheet added to spread


    objFpSpread.Sheets[objFpSpread.Sheets.Count - 1].DataSource = dtbOriginal;


    DataTable dtOLD = objFpSpread.ActiveSheet.GetDataView(true).ToTable();


    objFpSpread.ActiveSheetIndex = objFpSpread.Sheets.Count - 1;


    DataTable dtNEW= objFpSpread.ActiveSheet.GetDataView(true).ToTable();


    If u check  you can find dtOLD !=dtNEW;


    Thanks


    Snehasis


     


     


     


     

  • Replied 8 September 2017, 1:25 pm EST

    Any other way to create a carbon copy of an existing sheet (keeping consistency of data n look and feel) without Clone() method..


    Any suggetion..


    Thanks in advance..


    Ashis

  • Replied 8 September 2017, 1:25 pm EST

    Ashis,


    Instead of cloning the SheetView object, you can serialize the SheetView object. Before doing this and after making changes programatically to the original bound Spread control, you need to call the EndEdit method on each DataRow object that corresponds to the row you made the change to. This will update the bound DataSet with the changes made to the Spread.

  • Replied 8 September 2017, 1:25 pm EST

    Hi Scott


    thanks a lot.. Please give an example as I am new in farpoint ...How to serialize the SheetView object ?


    Is it like this , but it is showing some error..


    public FarPoint.Win.Spread.SheetView CopySheet(FarPoint.Win.Spread.SheetView sheet)


    {


    FarPoint.Win.Spread.SheetView newSheet = null;


    if (sheet != null)


    {


    newSheet = FarPoint.Win.Serializer.LoadObjectXml(GetType(FarPoint.Win.Spread.SheetView), FarPoint.Win.Serializer.GetObjectXml(sheet, "CopySheet"), "CopySheet");


    }


    return newSheet;


    }


    but some compilation error is there..


    Please have your suggetion..


    Thanks


    Ashis

  • Replied 8 September 2017, 1:25 pm EST

    Ashis -

    Here is a link to code the master wrote for serializing a sheet...

    http://www.clubfarpoint.com/Forums/forums/thread/20261.aspx

Need extra support?

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

Learn More

Forum Channels