Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i make a specific row bold?

I am working on generating a pdf and till now its going fine, but i want some specific rows to be bold. for example see picture : grid template from jspdf-autotable How can i make for example, row with id =1 and id=3 bold? Below my code.

function createPDF() {
            if(vm.activeCompanyYear){
                var url = "/coci/report/registry/"+vm.activeCompanyYear;

                DataApiService.callApi(url,null,"GET").then(function(reportData){

                    if(reportData){
                        var doc = new jsPDF('p', 'pt');
                        var row = 45;
                        addPdfHeader(doc, row, "");
                        doc.printingHeaderRow = true;
                        var columns = [ "Description", vm.activeCompanyYear,vm.activeCompanyYear-1, vm.activeCompanyYear-2,vm.activeCompanyYear-3,vm.activeCompanyYear-4,"% t.o.v.'13" ];

                        var rows = [];

                        for(var j=0; j<reportData.length; j++){
                            var obj = reportData[j];

                            if (!obj.description ) {obj.description = '';}

                            if (!obj.year5 ) {obj.year5 = '';}

                            if (!obj.year4 ) {obj.year4 = '';}

                            if (!obj.year3 ) {obj.year3 = '';}

                            if (!obj.year2 ) {obj.year2 = '';}

                            if (!obj.year1 ) {obj.year1 = '';}

                            if (!obj.delta ) {obj.delta = '';}


                            /*TODO : Align data right in grid*/

                            var singleRow = [obj.description,obj.year5,obj.year4,obj.year3,obj.year2,obj.year1,obj.delta];
                            rows.push(singleRow);

                        }                       

                        doc.autoTable(columns, rows, {
                            theme : 'grid',
                            styles: {
                                    halign: 'right',
                                     },
                            headerStyles: {
                                         fillColor: [33, 150, 243],
                                         halign:'center'
                            },
                            margin : {
                                top : 100
                                },
                            columnStyles:{
                                 0: {halign:'left'}
                            }

                        });


                        vm.isLoading = false;
                        blockUI.stop();
                        /* doc.save(); */
                        vm.reportData = doc.output('datauristring');

                    }
                });
            }
        }
like image 882
akshay bhoendie Avatar asked Jan 19 '17 14:01

akshay bhoendie


People also ask

How do you make a row bold in HTML?

You should use a style sheet. There is a simple typo: The / is missing in the second occurrence of <b> .

How do I make certain text bold?

To make text bold, select and highlight the text first. Then hold down Ctrl (the control key) on the keyboard and press B on the keyboard.

How do I bold the first row in Excel in C#?

You must pass value of row 0 so that first row of your excel sheets have column headers with bold font size. Just change DataColumnCollection to your columns name and change col. Caption to specific column name. You may do this to cell of excel sheet you want bold.


2 Answers

I tried it like the following and it worked :

 doc.autoTable(cols, data, { createdCell: function(cell, data) { if (data.row.index === 0 || data.row.index === 2) { cell.styles.fontStyle = 'bold'; } } })
like image 104
akshay bhoendie Avatar answered Sep 22 '22 13:09

akshay bhoendie


Something like this should work:

doc.autoTable({
  html: '#table',
  didParseCell: function(cell, data) {
    if (data.row.index === 0 || data.row.index === 2) {
      cell.styles.fontStyle = 'bold';
    }
  }
})
like image 36
Simon Bengtsson Avatar answered Sep 22 '22 13:09

Simon Bengtsson