Skip to content

Commit

Permalink
fix: clear converted sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuheiKubota committed Mar 9, 2023
1 parent 6b82b80 commit 517a3cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,23 @@ func (c globalCmd) convert(oc outputContext) error {
return nil
}

func (c globalCmd) tempSheetName(oc outputContext) string {
name := "_CSV2XLSX_TEMP_"
for {
if idx, _ := oc.output.GetSheetIndex(name); idx == -1 {
return name
}

name += "a"
}
}

func (c globalCmd) convertOne(oc outputContext, sheet string, input io.Reader) error {
tempname := c.tempSheetName(oc)
oc.output.NewSheet(tempname)
oc.output.DeleteSheet(sheet)
oc.output.NewSheet(sheet)
oc.output.DeleteSheet(tempname)

r := csv.NewReader(input)
if len(c.Delimiter) > 0 {
Expand Down

0 comments on commit 517a3cf

Please sign in to comment.