{"record":{"id":"ebe79c7b985545e3","repo":"iflytek/astron-agent","slug":"no-valid-data-in-file-please-check-if-excel-data-is-correct","errorCode":null,"errorMessage":"No valid data in file, please check if excel data is correct!","messagePattern":"No valid data in file, please check if excel data is correct!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DBExcelReadListener.java","lineNumber":111,"sourceCode":"\n            Object v;\n            if (StringUtils.isBlank(raw)) {\n                // Null value: required -> use field default value; not required -> type default value (or null)\n                v = chooseDefault(meta, notNullFieldsList.contains(header));\n            } else {\n                v = parseByType(raw, meta.getType());\n            }\n            out.put(header, v);\n        }\n\n        rowsSink.add(out);\n        accepted++;\n    }\n\n    @Override\n    public void doAfterAllAnalysed(AnalysisContext analysisContext) {\n        if (accepted == 0) {\n            throw new IllegalArgumentException(\"No valid data in file, please check if excel data is correct!\");\n        }\n    }\n\n    // Helper: Parse and default values\n\n    private Object parseByType(String s, String type) {\n        String t = StringUtils.lowerCase(type);\n        switch (t) {\n            case CommonConst.DBFieldType.INTEGER:\n                return Long.parseLong(s.trim());\n            case CommonConst.DBFieldType.NUMBER:\n                return new BigDecimal(s.trim());\n            case CommonConst.DBFieldType.BOOLEAN:\n                return parseBoolean(s);\n            case CommonConst.DBFieldType.TIME:\n                // Require standard format to avoid ambiguity in smart parsing\n                return LocalDateTime.parse(s.trim(), TS);\n            default:","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DBExcelReadListener.java#L93-L129","documentation":"DBExcelReadListener.doAfterAllAnalysed throws this IllegalArgumentException when the entire sheet was parsed but zero rows were accepted (accepted == 0). The import completed without any usable data rows, so the operation is rejected as an empty import. It only fires when all rows were skipped, invalid, or absent — rows beyond maxRows are silently ignored, but the first accepted row would prevent this.","triggerScenarios":"Uploading an Excel file containing only the header row with no data rows; a file where every row failed to parse before being added (e.g., cell values that throw inside invoke before accepted++ such as Long.parseLong failures); a file whose sheet selection points at an empty sheet.","commonSituations":"Users submit the template file unchanged without adding any data; wrong sheet is active so the populated data lives on another sheet; all data rows contain unparseable values that abort parsing before incrementing accepted.","solutions":["Add at least one valid data row under the header before importing.","Verify the correct worksheet/sheet index is being read (the sheet containing data, not an empty one).","Check that data cell values conform to field types (Integer/Number/Boolean/Time) so rows parse instead of aborting mid-invoke."],"exampleFix":"// before: template file uploaded with header only -> no rows\n// after: fill at least one row, e.g.\n// name | type | description | default | required\n// age  | Integer | user age | 0 | 是","handlingStrategy":"validation","validationCode":"// pre-flight: count non-empty data rows before import\ntry (var wb = org.apache.poi.ss.usermodel.WorkbookFactory.create(inputStream)) {\n    var sheet = wb.getSheetAt(0);\n    boolean hasData = sheet.getRowIterator().hasNext()\n            && sheet.getRow(0) != null && sheet.getLastRowNum() >= 1;\n    if (!hasData) throw new IllegalArgumentException(\"File contains no data rows\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    EasyExcel.read(file, listener).sheet().doRead();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"No valid data in file\")) {\n        // show user-facing message: add at least one data row\n    }\n}","preventionTips":["Fill at least one data row before importing.","Confirm the active sheet is the one with data (no extra empty sheets first).","Validate cell values against field types so rows parse successfully."],"tags":["excel","easyexcel","empty-file","java"],"backgroundTag":"empty-result-set","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}