Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kakilangit/excelsior
An excelize wrapper to separate the presentation and business logic
https://github.com/kakilangit/excelsior
excel excelize go
Last synced: 21 days ago
JSON representation
An excelize wrapper to separate the presentation and business logic
- Host: GitHub
- URL: https://github.com/kakilangit/excelsior
- Owner: kakilangit
- License: mit
- Created: 2022-01-16T09:48:14.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-04T08:22:38.000Z (6 months ago)
- Last Synced: 2024-06-21T11:50:38.944Z (5 months ago)
- Topics: excel, excelize, go
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/kakilangit/excelsior)
[](https://pkg.go.dev/github.com/kakilangit/excelsior)![Dall-E generated exelsior image](https://raw.githubusercontent.com/kakilangit/static/main/excelsior/excelsior.png)
# Excelsior
An excelize wrapper to separate the presentation and business logic.
```shell
go get -u -v github.com/kakilangit/excelsior
```
Example:
```go
package mainimport (
"log"
"os""github.com/kakilangit/excelsior"
"github.com/xuri/excelize/v2"
)// notFound implements excelsior.SheetData.
type notFound []string// Total return total data.
func (f notFound) Total() int {
return len(f)
}// Row represents excel row.
func (f notFound) Row(i int) excelsior.Row {
return []any{f[i]}
}func main() {
data, err := excelsior.Serialize(func(file *excelize.File, style excelsior.Style) ([]byte, error) {
const sheetName = "not found alphabet"excelsior.SetDefaultSheetName(file, sheetName)
headers := []any{"alphabet"}
rows := []string{"a", "b", "c"}sheet := excelsior.NewSheet(headers, excelsior.DefaultGetStyleFn, style.Header(), notFound(rows))
if err := sheet.Generate(file, sheetName); err != nil {
return nil, err
}return excelsior.Byte(file)
})
if err != nil {
log.Fatal(err)
}f, err := os.Create("alphabet.xlsx")
if err != nil {
log.Fatal(err)
}
defer func() { _ = f.Close() }()if _, err := f.Write(data); err != nil {
log.Fatal(err)
}if err := f.Sync(); err != nil {
log.Fatal(err)
}
}```
## License
MIT
Copyright (c) 2022 kakilangit