Set Bold,Italic and Underline a group of cells all at the same time

Posted by: robertobonilla2007 on 8 September 2017, 5:00 am EST

  • Posted 8 September 2017, 5:00 am EST

    I need set a group of cell Bold,Italic and Underline all at the same time. not individual like the example below, if not all together

    Dim si As New FarPoint.Win.Spread.StyleInfo

    Dim defFont As Font = FpSpread1.Sheets(0).Models.Style.GetCompositeInfo(f, c, -1, si).Font

    Dim rangeFont As Font

    rangeFont = New Font(defFont, FontStyle.Bold)

     

     How can i do? Crying

     Thanks in Advance

     RB

  • Posted 8 September 2017, 5:00 am EST

    Hello,

    I didn't find a way to define these three different style using the same object.

    You may create three different font styles using Font and then you can apply those font styles to a range of cells Below is the code snippet to do the same.

            FpSpread1.Sheets(0).Cells(1, 1, 5, 5).Text = "fvalue"

            Dim fbold As Font

            fbold = New Font("Comic Sans MS", 10, FontStyle.Bold)

            Dim fitalic As Font

            fitalic = New Font("Comic Sans MS", 10, FontStyle.Italic)

            Dim funderline As Font

            funderline = New Font("Comic Sans MS", 10, FontStyle.Underline)

            FpSpread1.Sheets(0).Cells(1, 1, 5, 5).Font = fbold

            FpSpread1.Sheets(0).Cells(1, 1, 5, 5).Font = fitalic

            FpSpread1.Sheets(0).Cells(1, 1, 5, 5).Font = funderline

     I hope it will help you.

     

     Thanks,

     

  • Posted 8 September 2017, 5:00 am EST

    Thanks DeepakSharma, foy quick reply

     Regards

     RB Indifferent

  • Posted 8 September 2017, 5:00 am EST

    RB,

    You can OR the FontStyles together you want for the new Font object.

    rangeFont = New Font(defFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline)

  • Posted 8 September 2017, 5:00 am EST

    Thanks scotts

    Work fine 

     Thanks a lot

    RB

  • Posted 29 October 2018, 9:59 pm EST

    Hi team,

    could you please help me to set multiple format on the group of cell by using angular.

    and then want to increase font size of selected group range.

    e.g. I want to set range(2,3,6,7) of cells data as bold and italic.

    and under line works fine for me. by using below code

    var selectedRanges = this.sheet.getSelections()[0];
        this.sheet.getRange(selectedRanges.row, selectedRanges.col, selectedRanges.rowCount, selectedRanges.colCount, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.underline);
    

    Note : when we increase font size with selected range then it remove bold/Italic format from cell.

    Regards

    Manoj

Need extra support?

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

Learn More

Forum Channels