A
Anonymous

Excel Comparator - Copy this React, Tailwind Component to your project

<!DOCTYPE html> <html lang="it"> <head> <meta charset="UTF 8"> <meta name="viewport" content="width=device width, initial scale=1.0"> <title>Confronto Excel e Ripristino Formattazione</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.3.0/exceljs.min.js"></script> </head> <body> <h1>Confronto File Excel e Ripristino Formattazione</h1> <input type="file" id="originalFile" accept=".xlsx"> <input type="file" id="copyFile" accept=".xlsx"> <button onclick="compareFiles()">Confronta e Ripristina</button> <script> async function compareFiles() { const originalFile = document.getElementById('originalFile').files[0]; const copyFile = document.getElementById('copyFile').files[0]; if (!originalFile || !copyFile) { alert('Per favore, seleziona entrambi i file.'); return; } const originalWorkbook = new ExcelJS.Workbook(); const copyWorkbook = new ExcelJS.Workbook(); // Carica il file originale await originalWorkbook.xlsx.load(await originalFile.arrayBuffer()); const originalSheet = originalWorkbook.worksheets[0]; // Presumiamo che ci sia solo un foglio // Carica il file copia await copyWorkbook.xlsx.load(await copyFile.arrayBuffer()); const copySheet = copyWorkbook.worksheets[0]; // Presumiamo che ci sia solo un foglio // Itera attraverso le celle e ripristina la formattazione dalla versione originale originalSheet.eachRow((row, rowIndex) => { row.eachCell((cell, colIndex) => { const originalCell = originalSheet.getCell(rowIndex, colIndex); const copyCell = copySheet.getCell(rowIndex, colIndex); // Copia la formattazione dalla cella originale alla cella della copia copyCell.style = originalCell.style; }); }); // Salva il nuovo file ripristinato const buffer = await copyWorkbook.xlsx.writeBuffer(); const blob = new Blob([buffer], { type: "application/vnd.openxmlformats officedocument.spreadsheetml.sheet" }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'ripristinato_copia.xlsx'; document.body.appendChild(a); a.click(); document.body.removeChild(a); } </script> </body> </html> Questo codice html funziona ma puoi aggiungere un controllo su tutte le celle, alcune formule non funzionano pur essendo scritte giuste

Prompt
Component Preview

About

ExcelComparator - Compare Excel files and restore formatting with ease. Built with React and Tailwind, it handles styles and cell for. Copy component code!

Share

Last updated 1 month ago