You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

xlsx.go 510 B

1234567891011121314151617181920212223242526272829
  1. package xlsx
  2. import (
  3. "github.com/casbin/casibase/util"
  4. "github.com/tealeg/xlsx"
  5. )
  6. func ReadXlsxFile(fileId string) [][]string {
  7. path := util.GetUploadXlsxPath(fileId)
  8. file, err := xlsx.OpenFile(path)
  9. if err != nil {
  10. panic(err)
  11. }
  12. res := [][]string{}
  13. for _, sheet := range file.Sheets {
  14. for _, row := range sheet.Rows {
  15. line := []string{}
  16. for _, cell := range row.Cells {
  17. text := cell.String()
  18. line = append(line, text)
  19. }
  20. res = append(res, line)
  21. }
  22. break
  23. }
  24. return res
  25. }

基于Casbin的开源AI领域知识库平台

Contributors (1)