Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/a631807682/xlsxp
Easier imports and exports with https://github.com/tealeg/xlsx
https://github.com/a631807682/xlsxp
Last synced: 8 days ago
JSON representation
Easier imports and exports with https://github.com/tealeg/xlsx
- Host: GitHub
- URL: https://github.com/a631807682/xlsxp
- Owner: a631807682
- License: mit
- Created: 2021-06-03T08:46:58.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-13T10:05:15.000Z (about 3 years ago)
- Last Synced: 2024-10-11T15:19:35.109Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 79.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xlsxp ![test](https://github.com/a631807682/xlsxp/actions/workflows/test.yml/badge.svg)
Easier imports and exports excel with [xlsx](https://github.com/tealeg/xlsx)## Description
> The `excel` tag defines what to import and export from `struct` to `XLXS`.### Import
1. `index` represents the order of data.
2. `parse` represents a method of parsing corresponds to the `format`.
### Export
1. `index` represents the order of data.
2. `header` represents the header to display.
3. `format` represents a method of formatting.
4. `default` represents what to display when the data is empty.
5. `width` represents the header width.### Export xlsx example
```go
type Test struct {
UserName string `json:"user_name" excel:"header(Student);index(0);default(---)"`
CompletePercent float64 `json:"complete_percent" excel:"header(Complete Percent);index(1);format(percent)"`
}datas := make([]Test, 0)
datas = append(datas, Test{
UserName: "A",
CompletePercent: 15.3,
})datas = append(datas, Test{
UserName: "B",
CompletePercent: 17.558,
})file := xlsx.NewFile()
err := xlsxp.ExportExcel(file, "sheet1", datas)
...
err := xlsxp.ExportExcel(file, "sheet2", datas)
...
file.Save(filepath)
...```
### Import xlsx example
```go
type Test struct {
CompletePercent float64 `json:"complete_percent" excel:"index(1);parse(percent)"`
UserName string `json:"user_name" excel:"index(0);"`
}targetDatas := make([]Test, 0)
err = xlsxp.ImportExcel(xlsxBuf.Bytes(), "sheet1", &targetDatas)
```### Notice
Not support huge amounts of data. See:
[xlsx/issues/539](https://github.com/tealeg/xlsx/issues/539)
[xlsx/blob/master/file.go#L169](https://github.com/tealeg/xlsx/blob/master/file.go#L169)
[xlsx/blob/master/file.go#L410](https://github.com/tealeg/xlsx/blob/master/file.go#L410)