Skip to content

Commit 5ef41da

Browse files
committed
update xlsx calls based on changed cell.String(), removed permissive and verbose options
1 parent fce65bd commit 5ef41da

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

cmds/xlsx2csv/xlsx2csv.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ Putting it all together in a shell script.
7676
// Application Options
7777
showSheetCount bool
7878
showSheetNames bool
79-
verbose bool
80-
permissive bool
8179
)
8280

8381
func sheetCount(workBookName string) (int, error) {
@@ -108,23 +106,12 @@ func xlsx2CSV(out io.Writer, workBookName, sheetName string) error {
108106
results := [][]string{}
109107
cells := []string{}
110108
if sheet, ok := xlFile.Sheet[sheetName]; ok == true {
111-
for i, row := range sheet.Rows {
109+
for _, row := range sheet.Rows {
112110
//FIXME: I would be nice to optionally only the columns you wanted to output from the sheet...
113111
cells = []string{}
114-
for j, cell := range row.Cells {
115-
val, err := cell.String()
116-
if err != nil {
117-
if permissive == true {
118-
cells = append(cells, fmt.Sprintf("%s", val))
119-
} else {
120-
cells = append(cells, fmt.Sprintf("%s", err))
121-
}
122-
if verbose == true {
123-
fmt.Fprintf(os.Stderr, "row %d, col %d %s\n", i, j, err)
124-
}
125-
} else {
126-
cells = append(cells, val)
127-
}
112+
for _, cell := range row.Cells {
113+
val := cell.String()
114+
cells = append(cells, val)
128115
}
129116
results = append(results, cells)
130117
}
@@ -156,8 +143,6 @@ func init() {
156143
// App Specific Options
157144
flag.BoolVar(&showSheetCount, "c", false, "display number of sheets in Excel Workbook")
158145
flag.BoolVar(&showSheetNames, "n", false, "display sheet names in Excel W9rkbook")
159-
flag.BoolVar(&verbose, "verbose", false, "output cell level errors")
160-
flag.BoolVar(&verbose, "permissive", false, "ignore cell level errors")
161146
}
162147

163148
func main() {

cmds/xlsx2json/xlsx2json.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ func xlsx2JSON(out *os.File, workBookName, sheetName string) error {
109109
for _, row := range sheet.Rows {
110110
cells = []string{}
111111
for _, cell := range row.Cells {
112-
val, err := cell.String()
113-
if err != nil {
114-
//val = fmt.Sprintf("%s", err)
115-
}
112+
val := cell.String()
116113
cells = append(cells, val)
117114
}
118115
results = append(results, cells)

0 commit comments

Comments
 (0)