How can I customize a random number of columns

How can I customize a random number of columns

lubro2021lubro2021 Posts: 2Questions: 1Answers: 0

Please I need to customize an excel sheet but I do not know number of columns in my excel sheet. It may be 10 columns or 30 or 40 all depends on user. My question how to access those columns to change the background color

Answers

  • colincolin Posts: 12,441Questions: 0Answers: 2,107

    This example here shows how to colour the columns. You can find the number of columns with columns().count() - then iterate through those columns in the spreadsheet.

    Colin

  • lubro2021lubro2021 Posts: 2Questions: 1Answers: 0

    Thanks for reply.

    1. Well how can I use columns().count()? please if you have an example let me know.
    2. The example you mention
      if ($('c[r=C'+x+'] t', sheet).text() === 'London') {
      $('row:nth-child('+x+') c', sheet).attr('s', '39');
      }

    That will color column 'C', I need to select all columns in the excel sheet, so if I have column A, B, C, D, E in excel I need a code that loop over those columns. If I have column A, B, C, D, E, F, G in excel I need a code that a loop over those columns. In short I need code that loop over columns dynamically whatever the number of columns.

  • colincolin Posts: 12,441Questions: 0Answers: 2,107

    This updated example here should help you get that loop going: http://live.datatables.net/sesugofi/1/edit

    Colin

Sign In or Register to comment.