Skip to content

Commit 10d6c30

Browse files
committed
Revert to original plus TestIssue47 added
1 parent 5397868 commit 10d6c30

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

comparexlsxlsx.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package xls
2+
3+
import (
4+
"fmt"
5+
"github.com/tealeg/xlsx"
6+
"path"
7+
)
8+
9+
//Compares xls and xlsx files
10+
func compareXlsXlsx(filepathname string) string {
11+
xlsFile, err := Open(path.Join("testdata", filepathname)+".xls", "utf-8")
12+
if err != nil {
13+
return fmt.Sprintf("Cant open xls file: %s", err)
14+
}
15+
16+
xlsxFile, err := xlsx.OpenFile(path.Join("testdata", filepathname) + ".xlsx")
17+
if err != nil {
18+
return fmt.Sprintf("Cant open xlsx file: %s", err)
19+
}
20+
21+
for sheet, xlsxSheet := range xlsxFile.Sheets {
22+
xlsSheet := xlsFile.GetSheet(sheet)
23+
if xlsSheet == nil {
24+
return fmt.Sprintf("Cant get xls sheet")
25+
}
26+
for row, xlsxRow := range xlsxSheet.Rows {
27+
xlsRow := xlsSheet.Row(row)
28+
for cell, xlsxCell := range xlsxRow.Cells {
29+
xlsText := xlsRow.Col(cell)
30+
xlsxText := xlsxCell.String()
31+
if xlsText != xlsxText {
32+
return fmt.Sprintf("Sheet: %d, row: %d, col: %d, xlsx: (%s)[%d], xls: (%s)[%d].",
33+
sheet, row, cell, xlsxText, len(xlsxText), xlsText, len(xlsText))
34+
}
35+
}
36+
}
37+
}
38+
39+
return ""
40+
}

issue47_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package xls
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestIssue47(t *testing.T) {
8+
e := compareXlsXlsx("issue47")
9+
10+
if e != "" {
11+
t.Fatalf("XLS an XLSX are not equal: %s", e)
12+
}
13+
14+
}

testdata/bigtable.xls

1.2 MB
Binary file not shown.

testdata/bigtable.xlsx

298 KB
Binary file not shown.

testdata/issue47.xls

198 KB
Binary file not shown.

testdata/issue47.xlsx

55.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)