Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

411
Views
Missing Macros and vba after modifying excel xlsm using Javascript library Sheetjs

I am using Sheetjs to edit an existing file of excel with extension xlsm macro enabled. It works but after downloading output file, all the styling, macro and vba script gets deleted. here is the code which I am using

<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.2/xlsx.full.min.js" integrity="sha512-oCjkwxjURabnte5K4Zeoc+hZ/G5pQE7GI4DYl+0wl6WaJIkBjb9FvUIaMU3lOPoBMSRZZ7QrczpGQoBFAKKB1Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
    (async () => {
        const url = "{{ URL('/') }}/test.xlsm"
        const data = await (await fetch(url)).arrayBuffer();
        /* data is an ArrayBuffer */
        //   const workbook = XLSX.read(data);
        try {
            const workbook = XLSX.read(data, {
                bookVBA: true,
                type:'binary'
            });

            let worksheet = workbook.Sheets['Raw Data'];
            var desired_cell = worksheet['B8'];
            var desired_value = (desired_cell ? desired_cell.v : undefined);
          
            XLSX.utils.sheet_add_aoa(worksheet, [
                ['NEW VALUE from NODE']
            ], {
                origin: 'B8'
            });
            XLSX.utils.sheet_add_aoa(worksheet, [
                ['NEW VALUE from NODE']
            ], {
                origin: 'B9'
            });
            XLSX.writeFile(workbook, './out.xlsm', {
                bookVBA: true,
                type:'binary'
                
            });
            console.log('Completed ...');

        } catch (error) {
            console.log(error.message);
            console.log(error.stack);
        }

    })();
</script>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!