42 lines
680 B
Go
42 lines
680 B
Go
package biz
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
QueryLImit = 10
|
|
ExcelMaxRow = 10
|
|
)
|
|
|
|
func getFielName(path, filename string, time time.Time) string {
|
|
if path == "" {
|
|
path, _ = os.Getwd()
|
|
}
|
|
date := time.Format("20060102")
|
|
return fmt.Sprintf("%s/%s_%s_%%d.xlsx", path, filename, date)
|
|
}
|
|
|
|
type ExportOpts struct {
|
|
QueryLimit int
|
|
ExcelMaxRow int
|
|
Path string
|
|
Tag string
|
|
}
|
|
|
|
var DefaultOpts *ExportOpts = &ExportOpts{
|
|
QueryLimit: QueryLImit,
|
|
ExcelMaxRow: ExcelMaxRow,
|
|
Tag: "export",
|
|
}
|
|
|
|
func NewExportOpts(query, limit int, path string) *ExportOpts {
|
|
return &ExportOpts{
|
|
QueryLimit: query,
|
|
ExcelMaxRow: limit,
|
|
Path: path,
|
|
}
|
|
}
|