21
0
Fork 0

Revert to original plus TestIssue47 added

This commit is contained in:
sergeilem 2018-10-02 23:30:18 +03:00
parent 539786826c
commit 10d6c30f15
6 changed files with 54 additions and 0 deletions

40
comparexlsxlsx.go Normal file
View File

@ -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 ""
}

14
issue47_test.go Normal file
View File

@ -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)
}
}

BIN
testdata/bigtable.xls vendored Normal file

Binary file not shown.

BIN
testdata/bigtable.xlsx vendored Normal file

Binary file not shown.

BIN
testdata/issue47.xls vendored Normal file

Binary file not shown.

BIN
testdata/issue47.xlsx vendored Normal file

Binary file not shown.