https://github.com/hungrybluedev/xlsx
V library to add support for Microsoft Excel files.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.2%) to scientific vocabulary
Keywords
Repository
V library to add support for Microsoft Excel files.
Basic Info
Statistics
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 2
- Releases: 0
Topics
Metadata Files
README.md
xlsx
Description
A package in pure V for reading and writing (soon) Excel files in the XLSX format.
Roadmap
- [x] Read XLSX files.
- [ ] Write XLSX files.
Installation
bash
v install https://github.com/hungrybluedev/xlsx
Usage
Reading XLSX files
Take the data.xlsx file from the examples/01_marksheet directory for this example.
```v import xlsx
fn main() { workbook := xlsx.Document.from_file('path/to/data.xlsx')! println('[info] Successfully loaded workbook with ${workbook.sheets.len} worksheets.')
println('\nAvailable sheets:')
// sheets are stored as a map, so we can iterate over the keys.
for index, key in workbook.sheets.keys() {
println('${index + 1}: "${key}"')
}
// Excel uses 1-based indexing for sheets.
sheet1 := workbook.sheets[1]
// Note that the Cell struct is able to the CellType.
// So we can have an idea of what to expect before getting all
// the data as a dataset with just string data.
dataset := sheet1.get_all_data()!
count := dataset.row_count()
println('\n[info] Sheet 1 has ${count} rows.')
headers := dataset.raw_data[0]
println('\nThe headers are:')
for index, header in headers {
println('${index + 1}. ${header}')
}
println('\nThe student names are:')
for index in 1 .. count {
row := dataset.raw_data[index]
// All data is stored as strings, so we need to convert it to the appropriate type.
roll := row[0].int()
name := row[1] + ' ' + row[2]
println('${roll:02d}. ${name}')
}
} ```
Remember to replace 'path/to/data.xlsx' with the actual path to the file.
After you are done, run the program:
bash
v run marksheet.v
You should see the following output:
```plaintext [info] Successfully loaded workbook with 1 worksheets.
Available sheets: 1: "1"
[info] Sheet 1 has 11 rows.
The headers are: 1. Roll Number 2. First Name 3. Last Name 4. Physics 5. Chemistry 6. Biology 7. Mathematics 8. Total 9. Percentage
The student names are: 01. Priya Patel 02. Kwame Nkosi 03. Mei Chen 04. Aisha Adekunle 05. Javed Khan 06. Mei-Ling Wong 07. Oluwafemi Adeyemi 08. Yuki Takahashi 09. Rashid Al-Mansoori 10. Sanya Verma ```
Try running the example on other XLSX files to see how it works. Modify the example to suit your needs.
Writing XLSX files
Coming soon!
Get Involved
It is a good idea to have examples files ready for testing. Ideally, the test files should be as small as possible.
If it is a feature request, please provide a detailed description of the feature and how it should work.
On GitHub
- Create issues for bugs you find or features you want to see.
- Fork the repository and create pull requests for contributions.
On Discord
- Join the V Discord server: https://discord.gg/vlang
- Write in the
#xlsxchannel about your ideas and what you want to do.
License
This project is licensed under the MIT License. See LICENSE for more details.
Support
If you like this project, please consider supporting me on GitHub Sponsors.
Resources
Owner
- Name: Subhomoy Haldar
- Login: hungrybluedev
- Kind: user
- Location: United Kingdom
- Company: @Coders-Compass
- Website: https://hungrybluedev.in/
- Repositories: 66
- Profile: https://github.com/hungrybluedev
Experienced polyglot developer and published author specializing in full-stack systems, DevOps, and technical architecture.