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

117
Views
Lectura y escritura simples en SheetJs angulares que no conservan el estilo y las macros del archivo xlsm

Tengo un archivo xlsm en la carpeta de activos, que necesito leer y devolver como archivo de descarga. Puedo leer el archivo.

El siguiente código, que básicamente descarga el blob como un archivo, conserva las macros y el estilo.

 this.http.get(..., {responseType: 'blob' as 'json'}).subscribe((response:any)=>{ let dataType = response.type; let binaryData = []; binaryData.push(response); let downloadLink = document.createElement('a'); downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, {type: dataType})); if (this.fileName) downloadLink.setAttribute('download', this.fileName); document.body.appendChild(downloadLink); downloadLink.click(); });

Sin embargo, necesito modificar algunos datos y estoy usando SheetJs (xlsx) para modificarlos, pero no conserva las macros ni el estilo.

El siguiente código usa xlsx para simplemente leerlo y escribirlo en un archivo y aún pierde macros y estilo, solo conserva los datos.

 this.http.get(..., {responseType: 'blob' as 'json'}).subscribe((response:any)=>{ const reader: FileReader = new FileReader(); reader.onload = (e: any) => { const bstr: string = e.target.result; const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary', bookVBA :true, cellStyles:true, cellHTML:true }); XLSX.writeFile(wb, this.fileName,{ type: 'binary', bookVBA:true, bookType: 'xlsm', cellStyles:true, bookSST:true, }); }; reader.readAsBinaryString(response); });

incluso después de establecer bookVBA y cellStyles en verdadero no se resuelve.

Estoy usando la última versión de SheetJs

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!