0% found this document useful (0 votes)
53 views

Column in

The document discusses using npm-xlsx to export data to an Excel sheet. When data in a column has more than 255 characters, it gets truncated. The code shown sets the column widths using the ColInfo type, but comments are still truncated if they exceed 255 characters. The question asks how to save the file without truncation and what parameter needs to be set in xlsx.

Uploaded by

ashish877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Column in

The document discusses using npm-xlsx to export data to an Excel sheet. When data in a column has more than 255 characters, it gets truncated. The code shown sets the column widths using the ColInfo type, but comments are still truncated if they exceed 255 characters. The question asks how to save the file without truncation and what parameter needs to be set in xlsx.

Uploaded by

ashish877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

I am using npm-xlxs sheet to export the data into excel sheet.

But if my data is
more than 255 character then it is getting truncated.

There is one writing option given(sharing code below) in the link for modifying
column but it is not working out -

type ColInfo = {
/* visibility */
hidden?: boolean; // if true, the column is hidden

/* column width is specified in one of the following ways: */


wpx?: number; // width in screen pixels
width?: number; // width in Excel's "Max Digit Width", width*256 is integral
wch?: number; // width in characters

/* other fields for preserving features from files */


MDW?: number; // Excel's "Max Digit Width" unit, always integral
};
Here is the code that I have tried-

export(){
let wscols = [
{width:256},
{width:5120},
{width:256}
];
let data:any[]=[];
for (let i=0; i<res.length; i++){
data.push({
'Name' : res[i].name,
'Comment' : res[i].comment,
'Age' : res[i].age
});
}
const ws: XLSX.WorkSheet=XLSX.utils.json_to_sheet(data);
const wb: XLSX.WorkBook = XLSX.utils.book_new();
ws['!cols'] = wscols;
XLSX.utils.book_append_sheet(wb, ws, 'Detail');
XLSX.writeFile(wb, 'Detail_Table.xls');
}
Here if my comment column is greater than 255 character then it is getting
truncated.

How to save the file without truncation? What parameter I am missing to set in
xlsx?

You might also like