How to use the writeFile function from xlsx

Find comprehensive JavaScript xlsx.writeFile code examples handpicked from public code repositorys.

67
68
69
70
71
72
73
74
75
76
    var ws = sheet_from_array_of_arrays(twodarr);
    wb.Sheets[sheetdispname] = ws;
    if (process.env.debug)
      console.log(filename, '/', sheetdispname);
  }
  xlsx.writeFile(wb, filename);
}

function convertObjArray(objarray) {
  try {
fork icon15
star icon23
watch icon3

53
54
55
56
57
58
59
60
61
62
    }


    var wopts = { bookType:'xlsx', bookSST:true, type:'binary' };
    var filename = path.join(os.tmpdir(), uuid.v1()+'.xlsx');
    xlsx.writeFile(wb, filename, wopts);

    callback(null, filename);
  });
}
fork icon3
star icon6
watch icon13

136
137
138
139
140
141
142
143
144
    var ws_name = "Ark1";
    var wb = new Workbook();
    var ws = sheet_from_array_of_arrays(data);  
    wb.SheetNames.push(ws_name);
    wb.Sheets[ws_name] = ws;
    XLSX.writeFile(wb, outputFileName);
}

// END WORKBOOK STUFF
fork icon1
star icon0
watch icon6

92
93
94
95
96
97
98
99
100
101
102
//可以创建成功
function createFile() {
    var ws = xlsx.utils.aoa_to_sheet(data);
    var wb = xlsx.utils.book_new();
    xlsx.utils.book_append_sheet(wb, ws, "SheetJS");
    xlsx.writeFile(wb, 'out.xlsx');
}


// createFile()
//可以读取成功
fork icon0
star icon1
watch icon2

101
102
103
104
105
106
107
108
109
110
        fs.unlinkSync(path)
    } catch(err) {
        console.error(err)
    }

    XLSX.writeFile(workbook, Helpers.publicPath('download/'+filename));
})();

return { uri: 'download/' + filename}
  
fork icon2
star icon0
watch icon2

+ 3 other calls in file

16
17
18
19
20
21
22
23
24
25


  const workbook = XLSX.utils.book_new()


  XLSX.utils.book_append_sheet(workbook, worksheet, '数据')


  XLSX.writeFile(workbook, path.resolve(__dirname, 'output.xlsx'))
}
fork icon0
star icon0
watch icon1

+ 2 other calls in file

348
349
350
351
352
353
354
355
356
357
console.log(data);
var temp = JSON.stringify(data); // Convert JSON to Json string
temp = JSON.parse(temp); // Convert to object
var ws = xlsx.utils.json_to_sheet(temp); // Convert Json Object into sheet of EXCEL
xlsx.utils.book_append_sheet(wb, ws, "sheet1"); //Append sheets into wb
xlsx.writeFile(
  //Now creating new file with unique name and writing EXCEL data to it
  wb,
  (path1 = path.join(
    __dirname,
fork icon0
star icon0
watch icon1

+ 7 other calls in file

83
84
85
86
87
88
89
90
91
92
93
        console.log('ERROR', err.message);
    }


    let ws = XLSX.utils.aoa_to_sheet(ws_data);
    XLSX.utils.book_append_sheet(wb, ws, first_sheet_name);
    XLSX.writeFile(wb, EXCEL_CUSTOMER_FILE);
}


module.exports = customer;
fork icon0
star icon0
watch icon1

+ 4 other calls in file

345
346
347
348
349
350
351
352
353
354
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleanList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Inputs');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Inputs.xlsx');
};

//BUSQUEDA
const handleSearchValues = (event) => {
fork icon0
star icon0
watch icon1

84
85
86
87
88
89
90
91
92
93
94
95
      const sheet = XLSX.utils.json_to_sheet(json);


      XLSX.utils.book_append_sheet(book, sheet, NAME[key]);
    }


    XLSX.writeFile(book, resolve(__dirname, `../generated/missing-icons.xlsx`));
  } catch (error) {
    console.error(error);
  }
})();
fork icon0
star icon0
watch icon1

103
104
105
106
107
108
109
110
111
112
113
        sheet[el[0]] = {
            t: type,
            v: el[1]
        }
    })
    xlsx.writeFile(workbook, config.newFile)
}


export function xlsx_upload() {
    
fork icon0
star icon0
watch icon1

268
269
270
271
272
273
274
275
276
277
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleanList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Inventory');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Inventory.xlsx');
};

return (
  <Card sx={{p: 4}}>
fork icon0
star icon0
watch icon1

72
73
74
75
76
77
78
79
80
81
82
                const json = XLSX.utils.sheet_to_json(sheet);


                // Save the JSON data to a file
                const jsonName = `data${index}.json`;
                const jsonPath = `${folderPath}/dataFromExcel/${jsonName}`;
                XLSX.writeFile(json, jsonPath);
            });
        });
    });
});
fork icon0
star icon0
watch icon1

376
377
378
379
380
381
382
383
384
385
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleanList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Products');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Products.xlsx');
};

//FUNCIONES MENU
const [anchorEl, setAnchorEl] = React.useState(null);
fork icon0
star icon0
watch icon1

132
133
134
135
136
137
138
139
140
141
    return;
  }
  const file = reader.readFile('../exported.xlsx')
  const ws = reader.utils.json_to_sheet(results)
  reader.utils.book_append_sheet(file, ws, "sheet2")
  reader.writeFile(file, './test.xlsx')
  return res.json({
    success: 1
  });
});
fork icon0
star icon0
watch icon1

+ 9 other calls in file

507
508
509
510
511
512
513
514
515
516
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleanList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Outputs');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Outputs.xlsx');
};

const getDateParsed = () => {
  let date = new Date();
fork icon0
star icon0
watch icon1

+ 3 other calls in file

255
256
257
258
259
260
261
262
263
264
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleanList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Clients');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Clients.xlsx');
};

//FUNCIONES MENU
const [anchorEl, setAnchorEl] = React.useState(null);
fork icon0
star icon0
watch icon1

+ 3 other calls in file

259
260
261
262
263
264
265
266
267
268
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleaneList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Providers');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Providers.xlsx');
};

//FUNCIONES MENU
const [anchorEl, setAnchorEl] = React.useState(null);
fork icon0
star icon0
watch icon1

+ 3 other calls in file

263
264
265
266
267
268
269
270
271
272
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleaneList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Carriers');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Carriers.xlsx');
};

//FUNCIONES MENU
const [anchorEl, setAnchorEl] = React.useState(null);
fork icon0
star icon0
watch icon1

+ 3 other calls in file

257
258
259
260
261
262
263
264
265
266
const exportDoc = () => {
  var ws = XLSX.utils.json_to_sheet(cleaneList());
  var wb = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(wb, ws, 'Drivers');
  XLSX.utils.sheet_add_aoa(ws, [headersExcel], {origin: 'A1'});
  XLSX.writeFile(wb, 'Drivers.xlsx');
};

//FUNCIONES MENU
const [anchorEl, setAnchorEl] = React.useState(null);
fork icon0
star icon0
watch icon1

+ 3 other calls in file