https://github.com/redtoad/exceldb
A pure Go library importing XLSX files directly into an SQLite database
https://github.com/redtoad/exceldb
Last synced: 5 months ago
JSON representation
A pure Go library importing XLSX files directly into an SQLite database
- Host: GitHub
- URL: https://github.com/redtoad/exceldb
- Owner: redtoad
- License: mit
- Created: 2021-08-06T07:39:12.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-08T07:16:12.000Z (almost 4 years ago)
- Last Synced: 2024-06-21T13:01:50.080Z (almost 2 years ago)
- Language: Go
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# exceldb
exceldb is a pure Go library importing XLSX files directly into an SQLite database.
```go
package main
import (
"fmt"
"github.com/redtoad/exceldb"
)
func main() {
path := "Book1.xlsx"
db, err := exceldb.LoadFromExcel(path, exceldb.InMemoryDb,
exceldb.DateColum("Date", "01/02/06"))
if err != nil {
panic(err)
}
defer db.Close()
rows, err := db.Query(`SELECT
strftime("%m-%Y", "Date") as 'month-year',
Employee,
SUM("Hours worked")
FROM data
WHERE "Status" != "non billable"
GROUP BY strftime("%m-%Y", "Date"), Employee;`)
if err != nil {
panic(err)
}
defer rows.Close()
for rows.Next() {
var monthYear string
var resource string
var sum float64
if err := rows.Scan(&monthYear, &resource, &sum); err != nil {
panic(err)
}
fmt.Printf("%s -> %s -> %f\n", monthYear, resource, sum)
}
}
```
## TODOs
* Load mutliple XLSX files
* Guess column data type from cell format
## Changes
### 0.8.1 (2022-07-07)
* Fix support for date values.
### 0.8.0 (2021-08-08)
* Initial release.
## License
This program is published under the terms of the MIT License.