Excel cell formatting - How can we iterate excel export rows and get the cell value dynamically??
Excel cell formatting - How can we iterate excel export rows and get the cell value dynamically??
// Loop over the cells in column C
$('row c[r^="C"]', sheet).each( function () {
// Get the value
if ( $('is t', this).text() == 'New York' ) {
$(this).attr( 's', '20' );
}
});
In this example,they are looping over cells in 'C' column..how can we get this column A,B,C,D .... index position dynamically without specifying it??
This question has accepted answers - jump to:
Answers
This is a string. You can substitute the
C
with a variable like this:How you choose whether its
A
orB
, etc is up to your specific requirements.kevin
thank you for your answer..In an attached image,excel has 1st row as table title and 2nd row contains headers for each column,and remaining rows contains values for that headers..Based on header,i want to apply conditional formatting for cells in column.For example: header ****score1***column values should have conditional formatting..so how can we get column values based header??
You can use
table().header()
to get the table header. Here is an example in the Excel export customize function.http://live.datatables.net/zagelija/1/edit
Kevin
how can we get column cell position based on cell value in excel export?
Not sure I understand the question. It sounds like you are asking how to determine the Excel column letter from the position in array header array generated in my example (the
titles
variable). One way would be to build a mapping object like this:Then use indexOf() to get the index in the array and use the index to get the Excel column letter, like this:
Is this what you are asking about?
Kevin