Setting a table or cell style does not work
See original GitHub issueHi, The table style has been revised in accordance with xlsx-style , But it doesn’t work . i dont know how to do.
This is my full code:
const saveAs = require('file-saver').saveAs
const XLSX = require('xlsx')
/**
* export xlsx demo
* @param {[type]} data [description]
* @return {[type]} [description]
*/
module.exports = function (data) {
// iterator data
function sheet_from_array_of_arrays (data, options) {
const ws = {}
const range = {
s: {
c: 1000000,
r: 1000000
},
e: {
c: 0,
r: 0
}
}
for ( let R = 0; R != data.length; ++R ) {
for ( let C = 0; C != data[R].length; ++C ) {
if ( range.s.r > R ) range.s.r = R
if ( range.s.c > C ) range.s.c = C
if ( range.e.r < R ) range.e.r = R
if ( range.e.c < C ) range.e.c = C
// cell
const cell = {
v: data[R][C]
}
// cell_ref
const cell_ref = XLSX.utils.encode_cell({
c: C,
r: R
})
// type check
if ( typeof cell.v === 'number') {
cell.t = 'n'
cell.s = {
numFmt: "0.00%"
}
}
else if (typeof cell.v === 'boolean') cell.t = 'b'
else cell.t = 's'
ws[cell_ref] = cell
}
}
if ( range.s.c < 1000000 ) ws['!ref'] = XLSX.utils.encode_range(range);
return ws;
}
const sheet_name = 'sheetName' // sheet name
// create xlsx object
function Workbook () {
if ( !( this instanceof Workbook ) ) return new Workbook()
this.SheetNames = []
this.Sheets = {}
}
// install wb object
const wb = new Workbook()
wb.SheetNames.push(sheet_name)
wb.Sheets[sheet_name] = sheet_from_array_of_arrays(data)
// write xlsx
const wxbot = XLSX.write(wb, {
type: 'binary',
bookSST: true,
bookType: 'xlsx',
cellStyles: true
})
// to blob
function sheet_to_blob (s) {
const buf = new ArrayBuffer(s.length)
const view = new Uint8Array(buf)
for ( let i = 0; i != s.length; ++i ) view[i] = s.charCodeAt(i) & 0xFF
return buf
}
// export xlsx with file-saver
saveAs(new Blob([sheet_to_blob(wxbot)], {
type: 'application/octet-stream'
}), 'test.xlsx')
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (3 by maintainers)
Top Results From Across the Web
Table and cell styles in InDesign - Adobe Support
In the Styles panel, double-click the style, or select the style and choose Style Options from the Styles panel menu. Note that this...
Read more >table style not applying cell styles - CreativePro Network
I noticed that some settings in InDesign (such as Table styles, or footnote formatting options) are merely 'recommendations', and get very ' ...
Read more >Styles not working in Tables - Microsoft Community
Do the following: In the Manage Styles dialog box, go to the Set Defaults tab and make sure that the default settings match...
Read more >About Working With Table and Cell Styles | AutoCAD 2020
When you create your own cell styles, you will start from a Label or Data type of cell. While you can modify the...
Read more >How to change Excel table styles and remove table formatting
If you don't like the default table format, you can easily change it by ... The Format Cells dialog will open, and you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is an issue with https://github.com/protobi/js-xlsx, when we add the full style support we will revisit this issue.
When will this issue be resolved?