CopySheet function error!

Posted by: lgw6237 on 8 September 2017, 4:15 am EST

    • Post Options:
    • Link

    Posted 8 September 2017, 4:15 am EST

    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;

    }

    red text error message is:

                        FarPoint.Win.Spread.SheetView is a "type",This assigns in context is invalid

  • Posted 8 September 2017, 4:15 am EST

    Hello,

    Without debugging this, I do not know for sure the syntax, but I believe the correct code would be newSheet.GetType() to get the Type of FarPoint.Win.Spread.SheetView/

  • Posted 8 September 2017, 4:15 am EST

    please help to debug this,if modify to newSheet.GetType() ,then new error happen.

  • Posted 8 September 2017, 4:15 am EST

    Hello,

    Could you post a small zipped project reproducing this issue for us to debug?

  • Posted 8 September 2017, 4:15 am EST

    There are some cases the spread cannot copy sheets…i also encountered this error… maybe because the sheets are complicated or in databound

  • Posted 8 September 2017, 4:15 am EST

    If you are using code from the original post, try something like the following instead:

    private void Form1_Load(object sender, EventArgs e)
    {
      fpSpread1.Sheets.Count = 3;
    }
    
    private void button1_Click(object sender, EventArgs e)
    {
      FarPoint.Win.Spread.SheetView s = new FarPoint.Win.Spread.SheetView();
      s.Cells[0, 0].Text = "test";
      FarPoint.Win.Spread.DrawingSpace.FourWayArrowShape sh = new FarPoint.Win.Spread.DrawingSpace.FourWayArrowShape();
      sh.Name = "Arrow";
      s.AddShape(sh);
      fpSpread1.Sheets.Add(CopySheet(s));
    }
    
    public FarPoint.Win.Spread.SheetView CopySheet(FarPoint.Win.Spread.SheetView sheet)
            {
                FarPoint.Win.Spread.SheetView newSheet = null;
                if (sheet != null)
                {
                    newSheet = (FarPoint.Win.Spread.SheetView)FarPoint.Win.Serializer.LoadObjectXml(typeof(FarPoint.Win.Spread.SheetView), FarPoint.Win.Serializer.GetObjectXml(sheet, "CopySheet"), "CopySheet");
                }
                return newSheet;
            }
    
    
  • Posted 11 October 2017, 3:02 am EST

    Hi have the same problem!

    have you resolved?

    Thanks

    Simone

  • Posted 12 October 2017, 2:49 am EST

    Hello,

    I used the above code to CopySheet with Spread Studio v10(latest) and got it working absolutely fine. Please refer to the attached sample application, test the same and let me know what issues are you facing while copying sheets?

    Thanks,

    Deepak Sharma

    SpreadWinCopySheet.zip

Need extra support?

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

Learn More

Forum Channels