diff --git a/comparexlsxlsx.go b/comparexlsxlsx.go new file mode 100644 index 0000000..080f50a --- /dev/null +++ b/comparexlsxlsx.go @@ -0,0 +1,40 @@ +package xls + +import ( + "fmt" + "github.com/tealeg/xlsx" + "path" +) + +//Compares xls and xlsx files +func compareXlsXlsx(filepathname string) string { + xlsFile, err := Open(path.Join("testdata", filepathname)+".xls", "utf-8") + if err != nil { + return fmt.Sprintf("Cant open xls file: %s", err) + } + + xlsxFile, err := xlsx.OpenFile(path.Join("testdata", filepathname) + ".xlsx") + if err != nil { + return fmt.Sprintf("Cant open xlsx file: %s", err) + } + + for sheet, xlsxSheet := range xlsxFile.Sheets { + xlsSheet := xlsFile.GetSheet(sheet) + if xlsSheet == nil { + return fmt.Sprintf("Cant get xls sheet") + } + for row, xlsxRow := range xlsxSheet.Rows { + xlsRow := xlsSheet.Row(row) + for cell, xlsxCell := range xlsxRow.Cells { + xlsText := xlsRow.Col(cell) + xlsxText := xlsxCell.String() + if xlsText != xlsxText { + return fmt.Sprintf("Sheet: %d, row: %d, col: %d, xlsx: (%s)[%d], xls: (%s)[%d].", + sheet, row, cell, xlsxText, len(xlsxText), xlsText, len(xlsText)) + } + } + } + } + + return "" +} diff --git a/issue47_test.go b/issue47_test.go new file mode 100644 index 0000000..ab5a713 --- /dev/null +++ b/issue47_test.go @@ -0,0 +1,14 @@ +package xls + +import ( + "testing" +) + +func TestIssue47(t *testing.T) { + e := compareXlsXlsx("issue47") + + if e != "" { + t.Fatalf("XLS an XLSX are not equal: %s", e) + } + +} diff --git a/testdata/bigtable.xls b/testdata/bigtable.xls new file mode 100644 index 0000000..e7c7481 Binary files /dev/null and b/testdata/bigtable.xls differ diff --git a/testdata/bigtable.xlsx b/testdata/bigtable.xlsx new file mode 100644 index 0000000..b54c6fb Binary files /dev/null and b/testdata/bigtable.xlsx differ diff --git a/testdata/issue47.xls b/testdata/issue47.xls new file mode 100644 index 0000000..866f246 Binary files /dev/null and b/testdata/issue47.xls differ diff --git a/testdata/issue47.xlsx b/testdata/issue47.xlsx new file mode 100644 index 0000000..146e84c Binary files /dev/null and b/testdata/issue47.xlsx differ