Import grades into Moodle from Excel or LibreOffice files
Moodle imports grades from CSV, where decimal commas and encodings break. Our free gradeimport_spreadsheet reads .xlsx and .ods grade sheets directly.
Short answer: Moodle can import grades from a CSV file, a pasted spreadsheet or XML, but not from the Excel or LibreOffice file teachers actually keep. Our free plugin, gradeimport_spreadsheet, adds Spreadsheet file (Excel, LibreOffice) under Grades > Import: upload the .xlsx or .ods file, match the columns, done.
This is the twenty-third plugin in our series: one plugin for each Moodle plugin type, each one teaching DevLMS Studio, our AI plugin builder, how that type works. We checked the Moodle plugins directory first: it lists no grade import plugins at all besides the three in core.
Why CSV goes wrong
- Excel set to French, German, Spanish or Arabic saves “15,5” with semicolons between columns. Moodle then reads the wrong columns, or refuses the grade.
- Plain “CSV” from Excel is not UTF-8, so accented and Arabic names in feedback come out broken.
- Formulas are saved as values or as text depending on how the file was exported.
A spreadsheet file stores numbers as numbers. The plugin reads them as they are: 15.5 stays 15.5 whatever the language of the computer that saved the file, and a formula gives the value it last showed.
How it works
- Go to Grades > Import in the course and choose Spreadsheet file (Excel, LibreOffice).
- Upload the file. The first sheet is read: the first row holds the column names, each next row one student.
- Match the columns as in the CSV import (which column identifies students, which column goes to which grade item or feedback) and upload.
There is no encoding or separator to choose. Empty rows are skipped, and a CSV renamed to .xlsx is refused with a message saying what to do. Old .xls files are not supported, because Moodle ships without the reader for them: save as .xlsx. It supports Moodle 4.5 LTS to 5.3. The code is on GitHub.
How a grade import plugin works
From Moodle 5.3’s own CSV import:
- A grade import plugin is one page in the course gradebook. Moodle lists it under Import for anyone who may import grades and has the plugin’s own permission.
- The hard parts (matching students by email, username or ID number, checking each grade against its item’s limits, writing to the gradebook in one go) already live in the CSV import. Our plugin only turns the spreadsheet into rows and hands them to that code, so a correct import gives exactly the same result as a correct CSV.
- Moodle already includes the PhpSpreadsheet library, so no extra software is needed on the server.
Tests import an .xlsx and an .ods file through a real browser, including a grade made by a formula, and check the grader report; a renamed CSV is refused. Unit tests cover decimals, Arabic text, formulas, empty rows and a full import with feedback.
Need a plugin like this for your own Moodle?
Describe it in DevLMS Studio and watch it built and tested in a real Moodle, or ask our team for a fixed price.
Open DevLMS Studio