Can anyone help identify what I'm doing wrong here...
# suitescript
j
Can anyone help identify what I'm doing wrong here. I'm able to generate the xlsx file, but the style defined for cell A1 isn't showing the increased font size and red color. I'm new to using the xlsx module.
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType suitelet
 * @NAmdConfig /SuiteScripts/configuration.json
 */
define(['N/file', 'xlsx'],
 function ( file, xlsx) {
    function onRequest(context) {

var workbook = xlsx.utils.book_new();
        var worksheet_data = [
            ['header1', 'header2'],
            ['data1', 'data2']
        ];
        var worksheet = xlsx.utils.aoa_to_sheet(worksheet_data);

        log.debug('Worksheet', worksheet)

        //Style Stuff

        worksheet['A1'].s = {
            font: {
                color: { rgb: "FF0000" },
                sz: 48
            }
        };

        //End Style Stuff
        
        xlsx.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
        
        var options = { bookType:'xlsx', bookSST:false, type:'base64' };
        var xlsxFileContent = xlsx.write(workbook, options);
        
        var fileObj = file.create({
            name: 'workbook.xlsx',
            fileType: file.Type.EXCEL,
            contents: xlsxFileContent,
            folder: 21323635
        });
        
        var fileId = fileObj.save();
        
        // Now you can serve this file as needed
        context.response.writeFile(fileObj, true);

    }
     return {
         onRequest: onRequest
     };
 });
e
I don't believe styling is supported on the community edition of SheetJS
j
Interesting. Thanks. Any other recommended AMD module I can use instead? Or can I simply pay for a pro version I can upload to my configuration instead.
e
I think you could get the pro version and it should work. I've never tried it.
j
Thanks for the help on this. I'll reach out to SheetJS to see what they say about this. 🙂