-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
197 lines (183 loc) · 6.21 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SheetSense Analyzer</title>
<script src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js"></script>
<script src="dist/sheetsense.browser.js"></script>
<style>
body {
font-family: system-ui, -apple-system, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: #f5f5f5;
}
.upload-container {
background: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
text-align: center;
margin-bottom: 2rem;
}
#drop-zone {
border: 2px dashed #ccc;
border-radius: 4px;
padding: 2rem;
margin: 1rem 0;
cursor: pointer;
}
#drop-zone.dragover {
border-color: #0066cc;
background: #f0f7ff;
}
.results {
background: white;
padding: 1rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.issue {
margin: 1rem 0;
padding: 1rem;
border-radius: 4px;
}
.error {
background: #fff5f5;
border-left: 4px solid #dc2626;
}
.warning {
background: #fffbeb;
border-left: 4px solid #d97706;
}
.info {
background: #f0f9ff;
border-left: 4px solid #0284c7;
}
.metadata {
background: #f8fafc;
padding: 1rem;
border-radius: 4px;
margin: 1rem 0;
}
.hidden {
display: none;
}
.footer {
text-align: center;
margin-top: 2rem;
color: #666;
}
.footer a {
color: #0066cc;
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="upload-container">
<h1>SheetSense Analyzer </h1>
<div id="drop-zone">
<p>Drop your Excel file here or click to choose</p>
<input type="file" id="file-input" accept=".xlsx,.xls" class="hidden">
</div>
</div>
<div id="results" class="results hidden">
<h2>Analysis Results</h2>
<div class="metadata">
<h3>Workbook Metadata</h3>
<div id="metadata-content"></div>
</div>
<div id="issues-container">
<h3>Issues Found</h3>
<div id="issues-content"></div>
</div>
</div>
<div class="footer">
<p>
<a href="https://ezy.ovh/bmicX" target="_blank">View on GitHub</a> |
Created by <a href="https://ezy.ovh/oEaFv" target="_blank">@asadbek064</a>
</p>
</div>
<script>
const dropZone = document.getElementById('drop-zone');
const fileInput = document.getElementById('file-input');
const results = document.getElementById('results');
const metadataContent = document.getElementById('metadata-content');
const issuesContent = document.getElementById('issues-content');
// Drag and drop handlers
dropZone.addEventListener('dragover', (e) => {
e.preventDefault();
dropZone.classList.add('dragover');
});
dropZone.addEventListener('dragleave', () => {
dropZone.classList.remove('dragover');
});
dropZone.addEventListener('drop', (e) => {
e.preventDefault();
dropZone.classList.remove('dragover');
const file = e.dataTransfer.files[0];
handleFile(file);
});
// Click to upload
dropZone.addEventListener('click', () => {
fileInput.click();
});
fileInput.addEventListener('change', (e) => {
const file = e.target.files[0];
handleFile(file);
});
function handleFile(file) {
const reader = new FileReader();
reader.onload = (e) => {
const data = new Uint8Array(e.target.result);
const workbook = XLSX.read(data,
{
type: 'buffer',
cellFormula: true,
cellNF: true,
cellText: true,
cellStyles: true,
cellDates: true,
raw: true
}
);
// Use the actual SheetSense package
const analyzer = new SheetSense.ExcelAnalyzer(workbook);
const analysis = analyzer.analyze();
displayResults(analysis);
};
reader.readAsArrayBuffer(file);
}
function displayResults(analysis) {
results.classList.remove('hidden');
// Display metadata
metadataContent.innerHTML = `
<p>Sheets: ${analysis.metadata.sheetCount}</p>
<p>Formulas: ${analysis.metadata.formulaCount}</p>
<p>Named Ranges: ${analysis.metadata.namedRanges.length}</p>
<p>Volatile Functions: ${analysis.metadata.volatileFunctions}</p>
<p>External References: ${analysis.metadata.externalReferences}</p>
`;
// Display issues
if (analysis.issues.length === 0) {
issuesContent.innerHTML = '<p>No issues found!</p>';
} else {
issuesContent.innerHTML = analysis.issues.map(issue => `
<div class="issue ${issue.severity}">
<strong>${issue.type.toUpperCase()}: ${issue.severity}</strong>
<p>${issue.message}</p>
<p>Location: Sheet "${issue.sheet}", Cell ${issue.cell}</p>
${issue.suggestion ? `<p>Suggestion: ${issue.suggestion}</p>` : ''}
</div>
`).join('');
}
}
</script>
</body>
</html>