1
PDW / Re: Excel naar PDW .ini converter
« Laatste bericht door PD7AC Gepost op Vandaag om 16:22:18 »heb een fout ontdekt, kan deze post niet aanpassen of verwijderen (helaas)
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Excel naar INI Converter</title>
<!-- SheetJS -->
<script src="https://cdn.jsdelivr.net/npm/xlsx/dist/xlsx.full.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
max-width: 900px;
margin: 40px auto;
padding: 20px;
background: #848181;
}
h1 {
margin-bottom: 10px;
}
.card {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
input[type=file] {
margin-bottom: 20px;
}
button {
padding: 10px 16px;
border: none;
background: #0078d7;
color: white;
border-radius: 6px;
cursor: pointer;
margin-right: 10px;
}
button:hover {
background: #005fa3;
}
textarea {
width: 100%;
height: 400px;
margin-top: 20px;
font-family: Consolas, monospace;
font-size: 14px;
padding: 10px;
box-sizing: border-box;
}
.info {
margin-bottom: 20px;
color: #555;
}
</style>
</head>
<body>
<div class="card">
<h1>Excel → INI Converter</h1>
<div class="info">
Upload een Excel bestand (.xlsx).<br>
Elke rij wordt automatisch omgezet naar het INI formaat.
</div><br><br>
<input type="file" id="excelFile" accept=".xlsx,.xls" />
<div>
<button onclick="convertExcel()">Converteren</button>
<button onclick="downloadIni()">Download INI</button>
</div>
<textarea id="output"></textarea>
</div>
<script>
let iniContent = "";
function csvValue(value, isString = false) {
if (value === undefined || value === null) value = "";
if (isString) {
return `"${String(value)}"`;
}
return value;
}
function convertExcel() {
const fileInput = document.getElementById('excelFile');
if (!fileInput.files.length) {
alert("Selecteer eerst een Excel bestand.");
return;
}
const file = fileInput.files[0];
const reader = new FileReader();
reader.onload = function(e) {
const data = new Uint8Array(e.target.result);
const workbook = XLSX.read(data, { type: 'array' });
const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
// Array van arrays
const rows = XLSX.utils.sheet_to_json(firstSheet, {
header: 1,
defval: ""
});
if (rows.length < 2) {
alert("Geen data gevonden.");
return;
}
// Eerste rij = headers
const dataRows = rows.slice(1);
let lines = [];
lines.push("[Filter]");
lines.push("");
lines.push(`FilterCount=${dataRows.length}`);
lines.push("");
dataRows.forEach(row => {
// Verwachte kolommen:
// 0 = enabled
// 1 = code1
// 2 = code2
// 3 = empty string
// 4 = 0
// 5 = 0
// 6 = 1
// 7 = 2
// 8 = 0
// 9 = empty string
const line = [
csvValue(row[0]),
csvValue(row[1], true),
csvValue(row[2], true),
csvValue(row[3], true),
csvValue(row[4]),
csvValue(row[5]),
csvValue(row[6]),
csvValue(row[7]),
csvValue(row[8]),
csvValue(row[9], true)
].join(",");
lines.push(line);
});
iniContent = lines.join("\n");
document.getElementById("output").value = iniContent;
};
reader.readAsArrayBuffer(file);
}
function downloadIni() {
if (!iniContent) {
alert("Eerst converteren.");
return;
}
const blob = new Blob([iniContent], { type: 'text/plain' });
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'filters.ini';
a.click();
}
</script>
</body>
</html>Dank je wel, de database is weer bijgewerkt.
Ik heb deze versie nu draaien. Als je iets van een log wil hebben weet je mij te vinden.