fix: resolve Excel extraction for JHS and SHS SF10 form parsing
This commit is contained in:
1 parent
acba1b4eb0
commit
e5b02614cc
2 files changed
+23
-14
No files matched your search
@@ -462,13 +462,18 @@ exports.extractTextFromFile = async (filePath, originalName = '', mimeType = '')
|
||||
}
|
||||
|
||||
const tabTexts = [];
|
||||
workbook.eachSheet((worksheet) => {
|
||||
for (const worksheet of workbook.worksheets) {
|
||||
const tabName = worksheet.name;
|
||||
const rowsText = [];
|
||||
const csvLines = [];
|
||||
worksheet.eachRow({ includeEmpty: false }, (row) => {
|
||||
const maxRows = Math.max(worksheet.rowCount || 0, 300);
|
||||
|
||||
for (let r = 1; r <= maxRows; r++) {
|
||||
const row = worksheet.getRow(r);
|
||||
const rowValues = [];
|
||||
row.eachCell({ includeEmpty: false }, (cell) => {
|
||||
let lastValStr = '';
|
||||
|
||||
for (let c = 1; c <= 150; c++) {
|
||||
const cell = row.getCell(c);
|
||||
let val = cell.value;
|
||||
if (val !== null && val !== undefined) {
|
||||
if (typeof val === 'object') {
|
||||
@@ -481,23 +486,26 @@ exports.extractTextFromFile = async (filePath, originalName = '', mimeType = '')
|
||||
} else if (Array.isArray(val.richText)) {
|
||||
val = val.richText.map(r => r.text).join('');
|
||||
} else {
|
||||
val = JSON.stringify(val);
|
||||
val = '';
|
||||
}
|
||||
}
|
||||
const str = String(val).trim();
|
||||
if (str.length > 0) {
|
||||
const str = String(val ?? '').trim();
|
||||
if (str.length > 0 && str !== lastValStr) {
|
||||
rowValues.push(str);
|
||||
lastValStr = str;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (rowValues.length > 0) {
|
||||
rowsText.push(rowValues.join(' '));
|
||||
csvLines.push(rowValues.map(v => `"${v.replace(/"/g, '""')}"`).join(','));
|
||||
}
|
||||
});
|
||||
const formattedRows = rowsText.join('\n');
|
||||
tabTexts.push(`--- TAB: ${tabName} ---\n${formattedRows}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (rowsText.length > 0) {
|
||||
tabTexts.push(`--- TAB: ${tabName} ---\n` + rowsText.join('\n'));
|
||||
}
|
||||
}
|
||||
text = tabTexts.join('\n\n');
|
||||
return text;
|
||||
}
|
||||
|
||||
+2
-1
@@ -148,7 +148,8 @@ Files backup/restore - mirror mode or zip -->
|
||||
- SF10 is equal to School Form 10, Form 137, Form 137-A, Student Permanent Record -->
|
||||
|
||||
# OCR PARSEER
|
||||
- middle name and extension not working, bulk add and add student
|
||||
- FIX JHS and SHS Form 137/SF10/School-Form-10 NOT WORKING
|
||||
- check these files for references: F:\SumbrerongBato\tis_rms_server\requirements\test
|
||||
|
||||
# STUDENT SCREEN
|
||||
- bring back background color chip for status in students table (windows) and card (android)
|
||||
|
||||
Reference in new issue
Block a user