77 lines
2.9 KiB
PHP
77 lines
2.9 KiB
PHP
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Excel Viewer</title>
|
||
<!-- Luckysheet Bağımlılıkları -->
|
||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/plugins/css/pluginsCss.css' />
|
||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/plugins/plugins.css' />
|
||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/css/luckysheet.css' />
|
||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/assets/iconfont/iconfont.css' />
|
||
|
||
<script src="https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/plugins/js/plugin.js"></script>
|
||
<script src="https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/luckysheet.umd.js"></script>
|
||
<!-- SheetJS için -->
|
||
<script src="https://cdn.jsdelivr.net/npm/xlsx@latest/dist/xlsx.full.min.js"></script>
|
||
</head>
|
||
<body>
|
||
<input type="file" id="fileInput" accept=".xlsx,.xls">
|
||
<div id="luckysheet" style="margin:0px;padding:0px;position:relative;width:100%;height:100vh;left: 0px;top: 0px;"></div>
|
||
|
||
<script>
|
||
// Luckysheet'i başlat
|
||
luckysheet.create({
|
||
container: 'luckysheet',
|
||
showinfobar: false,
|
||
data: [{
|
||
name: "Sheet1",
|
||
color: "",
|
||
status: 1,
|
||
order: 0,
|
||
data: [],
|
||
config: {},
|
||
index: 0
|
||
}]
|
||
});
|
||
|
||
// Excel dosyası yükleme
|
||
document.getElementById('fileInput').addEventListener('change', async (event) => {
|
||
const file = event.target.files[0];
|
||
const reader = new FileReader();
|
||
|
||
reader.onload = function(e) {
|
||
const data = new Uint8Array(e.target.result);
|
||
const workbook = XLSX.read(data, { type: 'array', cellStyles: true });
|
||
|
||
// Excel verilerini Luckysheet formatına dönüştür
|
||
const sheets = [];
|
||
|
||
workbook.SheetNames.forEach((sheetName, index) => {
|
||
const worksheet = workbook.Sheets[sheetName];
|
||
const jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
|
||
|
||
sheets.push({
|
||
name: sheetName,
|
||
color: "",
|
||
status: index === 0 ? 1 : 0,
|
||
order: index,
|
||
data: jsonData,
|
||
config: {},
|
||
index: index
|
||
});
|
||
});
|
||
|
||
// Luckysheet'i güncelle
|
||
luckysheet.destroy();
|
||
luckysheet.create({
|
||
container: 'luckysheet',
|
||
showinfobar: false,
|
||
data: sheets
|
||
});
|
||
};
|
||
|
||
reader.readAsArrayBuffer(file);
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|