Skip to content

Commit

Permalink
feat: Add support for synchronizing to xlsx files
Browse files Browse the repository at this point in the history
  • Loading branch information
shijilin0116 committed Nov 24, 2023
1 parent 0f75554 commit 7d69983
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sdk/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func parseRowsToXLSX(rows []interface{}, filename string) error {
}

// ParseRowsToCSV
func ParseRowsToCSV(rows []interface{}, filename string) error {
func parseRowsToCSV(rows []interface{}, filename string) error {
// 首先,检查 rows 是否为空
if len(rows) == 0 {
return errors.New("rows is empty")
Expand Down
2 changes: 1 addition & 1 deletion sdk/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Test_ParseRowsToCSV(t *testing.T) {

filename := "test.csv"

if err := ParseRowsToCSV(rows, filename); err != nil {
if err := parseRowsToCSV(rows, filename); err != nil {
t.Error(err)
}

Expand Down
7 changes: 6 additions & 1 deletion sdk/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (api *APIConfig) ParamEncode() string {
return api.params.Encode()
}

func SyncToCSV(fileName string, api APIConfig) (int64, error) {
mode := "csv"
return SyncToFile(mode, fileName, api)
}

func SyncToFile(mode string, fileName string, api APIConfig) (int64, error) {
c := GetOpenAPIClient()
api.SetDefault()
Expand All @@ -75,7 +80,7 @@ func SyncToFile(mode string, fileName string, api APIConfig) (int64, error) {
}
switch mode {
case "csv":
err = ParseRowsToCSV(rows, fileName)
err = parseRowsToCSV(rows, fileName)
case "xlsx":
err = parseRowsToXLSX(rows, fileName)
default:
Expand Down

0 comments on commit 7d69983

Please sign in to comment.