Export excel width size, based on header value
Export excel width size, based on header value
Molu
Posts: 16Questions: 3Answers: 0
export excel width size, based on header value. If in UI user re-arrange the column, width will remain same.
e.g- Name column is in index first - width can be col[1].attr("width",35);
but user rearrange the column and now Name column index is 4, so how can we set width based on column name.
This question has an accepted answers - jump to answer
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
http://live.datatables.net/xoxerowi/1/
@colin - Request you to pls help on this.
You mentioned re-ordering in the original post, but that's not possible in your example. Please can you give steps on how to reproduce the issue you want help with,
Colin
$('col', sheet).each(function(x) {
console.log(x)
console.log($('c[r=C'+x+'] t', sheet).text() );
if ($('c[r=C'+x+'] t', sheet).text() === 'Office') {
console.log("true");
Above code is not working can any one pls help
var arr=["A","B","C","D","E","F"];
for(let i=0;i<=6;i++){
console.log($('row c[r=arr[i]'+1+'] t', sheet).text() )
if($('row c[r=arr[i]'+1+'] t', sheet).text()==="Position"){}
arr++;
}
can any one help me on this, this code giving me error.
Start by looking at the OpenXML docs to see how the cell selector works. You have
if ($('c[r=C'+x+'] t'
wherex
is the column index from the loop. However this is iterating columnC
from row 0 to row 5 giving the output of the cells in column 0. What you need to do is map the index the corresponding Excel column letter, ie, 0 = A, 1 = B, etc.Stack Overflow has some options for this. I updated the test case to show this:
http://live.datatables.net/leyidetu/1/edit
If you have more than 26 columns you will need to add the modulo calculation.
Kevin
Thank you @kthorngren I am able to do so by below code, can you pls help me to do, text wrap of header column?
var arr=["A","B","C","D","E","F"];
$('col', sheet).each(function(x) {
const value=$('c[r='+arr[x]+'1] t', sheet).text();
console.log(value);