Skip to content

Commit

Permalink
Merge pull request #51 from future-architect/feature/dump
Browse files Browse the repository at this point in the history
dump command supports v2 format
  • Loading branch information
ma91n authored Feb 28, 2024
2 parents 9bef618 + 2c2ed83 commit e7484fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions cli/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@ func Dump(dbSource, targetFile string, tableNameArg, systemColumnArg string) err

_ = f.SetCellValue(sheetName, "A1", tableDef.Comment)
_ = f.SetCellValue(sheetName, "A2", tableDef.Name)
_ = f.SetCellValue(sheetName, "A8", "項目名")
_ = f.SetCellValue(sheetName, "A9", "項目物理名")
_ = f.SetCellValue(sheetName, "A3", "version")
_ = f.SetCellValue(sheetName, "B3", "2.0")
_ = f.SetCellValue(sheetName, "A5", "項目名")
_ = f.SetCellValue(sheetName, "A6", "項目物理名")

_ = f.SetColWidth(sheetName, "A", "A", 12.86)
_ = f.SetCellStyle(sheetName, "A8", "A9", rowHeaderStyle)
_ = f.SetCellStyle(sheetName, "A5", "A6", rowHeaderStyle)

for i, columnDef := range tableDef.Columns {
axisComment, _ := excelize.CoordinatesToCellName(2+i, 8)
axisName, _ := excelize.CoordinatesToCellName(2+i, 9)
axisComment, _ := excelize.CoordinatesToCellName(2+i, 5)
axisName, _ := excelize.CoordinatesToCellName(2+i, 6)

_ = f.SetCellValue(sheetName, axisComment, columnDef.Comment)
_ = f.SetCellValue(sheetName, axisName, columnDef.Name)
Expand Down Expand Up @@ -221,10 +223,10 @@ func Dump(dbSource, targetFile string, tableNameArg, systemColumnArg string) err

// Add 3 empty row
vCell, _ := excelize.CoordinatesToCellName(1+len(tableDef.Columns), 12)
_ = f.SetCellStyle(sheetName, "A10", vCell, rowStyle)
_ = f.SetCellValue(sheetName, "A10", "1")
_ = f.SetCellValue(sheetName, "A11", "2")
_ = f.SetCellValue(sheetName, "A12", "3")
_ = f.SetCellStyle(sheetName, "A7", vCell, rowStyle)
_ = f.SetCellValue(sheetName, "A7", "1")
_ = f.SetCellValue(sheetName, "A8", "2")
_ = f.SetCellValue(sheetName, "A9", "3")

// データレコードがあれば上書き
if len(records) > 0 {
Expand All @@ -234,7 +236,7 @@ func Dump(dbSource, targetFile string, tableNameArg, systemColumnArg string) err
_ = f.SetCellStyle(sheetName, "A10", vCell, rowStyle)

for i, record := range records {
rowNum := 10 + i
rowNum := 7 + i

vCell, _ := excelize.CoordinatesToCellName(1, rowNum)
_ = f.SetCellValue(sheetName, vCell, fmt.Sprint(i+1))
Expand Down
2 changes: 1 addition & 1 deletion exceltesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (e *exceltesing) CompareWithContext(_ context.Context, r CompareRequest) (b
}

if r.EnableDumpCSV {
if e.dumpBookAsCSV(r.TargetBookPath); err != nil {
if err := e.dumpBookAsCSV(r.TargetBookPath); err != nil {
return false, []error{fmt.Errorf("dump csv: %w", err)}
}
}
Expand Down

0 comments on commit e7484fb

Please sign in to comment.