how do I clear row formatting of a spread

Posted by: maneesh on 8 September 2017, 1:48 pm EST

  • Posted 8 September 2017, 1:48 pm EST

    I have some code that formats rows in a sheet (at the end of this post).

    The problem is that on refreshing data, I also want to clear the formatting that I did using this code.  Is there a simple way to do this?

    Formatting code:

                    string prevModel = "";
                    FarPoint.Win.LineBorder lineBorder3 = new FarPoint.Win.LineBorder(System.Drawing.SystemColors.InactiveBorder, 10, false, true, false, false);
                    foreach (Row r in sv.Rows)
                    {
                        if ((string)sv.Cells[r.Index, 0].Value != prevModel)
                        {
                            r.Border = lineBorder3;
                            r.Height = 30;
                            /// mark cells with model and region with Green (only if we have to show National level)
                            if (checkBoxShowAllRegions.Checked)
                            {
                                sv.Cells[r.Index, 0].BackColor = Color.LawnGreen;
                                sv.Cells[r.Index, 3].BackColor = Color.LawnGreen;
                            }
                            else
                            {
                                sv.Cells[r.Index, 0].BackColor = Color.White;
                                sv.Cells[r.Index, 3].BackColor = Color.White;
                            }
                        }
                        else
                        {
                            r.StyleName = "namedStyle1";
                            r.Height = 20;
                            /// mark cells with model and region with Green
                            sv.Cells[r.Index, 0].BackColor = Color.White;
                            sv.Cells[r.Index, 3].BackColor = Color.White;
                        }
                        prevModel = (string)sv.Cells[r.Index, 0].Value;
                    }

     

  • Replied 8 September 2017, 1:48 pm EST

    Hello Maneesh,


    You may make use of the DefaultSheetStyleModel which has a Clear method you can use to remove all the formatting of the cells.Below snippet will clear the formatting information of last 3 rows.

     ((FarPoint.Win.Spread.Model.DefaultSheetStyleModel)FpSpread1.Sheets(0).Models.Style).Clear(7, -1, 3, -1);

    Hope this helps.Thanks

Need extra support?

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

Learn More

Forum Channels