20
0

Removed issue47 test due to breaking changes in tealeg/xlsx

This commit is contained in:
Sergei Lemeshkin 2020-05-09 10:54:22 +03:00
parent 8fb566963b
commit b376268d90
14 changed files with 0 additions and 85 deletions

View File

@ -1,55 +0,0 @@
package xls
import (
"fmt"
"github.com/tealeg/xlsx"
"math"
"strconv"
)
//Compares xls and xlsx files
func CompareXlsXlsx(xlsfilepathname string, xlsxfilepathname string) string {
xlsFile, err := Open(xlsfilepathname, "utf-8")
if err != nil {
return fmt.Sprintf("Cant open xls file: %s", err)
}
xlsxFile, err := xlsx.OpenFile(xlsxfilepathname)
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 {
xlsxText := xlsxCell.String()
xlsText := xlsRow.Col(cell)
if xlsText != xlsxText {
//try to convert to numbers
xlsFloat, xlsErr := strconv.ParseFloat(xlsText, 64)
xlsxFloat, xlsxErr := strconv.ParseFloat(xlsxText, 64)
//check if numbers have no significant difference
if xlsErr == nil && xlsxErr == nil {
diff := math.Abs(xlsFloat - xlsxFloat)
if diff > 0.0000001 {
return fmt.Sprintf("sheet:%d, row/col: %d/%d, xlsx: (%s)[%d], xls: (%s)[%d], numbers difference: %f.",
sheet, row, cell, xlsxText, len(xlsxText),
xlsText, len(xlsText), diff)
}
} else {
return fmt.Sprintf("sheet:%d, row/col: %d/%d, xlsx: (%s)[%d], xls: (%s)[%d].",
sheet, row, cell, xlsxText, len(xlsxText),
xlsText, len(xlsText))
}
}
}
}
}
return ""
}

View File

@ -1,30 +0,0 @@
package xls
import (
"io/ioutil"
"path"
"path/filepath"
"strings"
"testing"
)
func TestIssue47(t *testing.T) {
testdatapath := "testdata"
files, err := ioutil.ReadDir(testdatapath)
if err != nil {
t.Fatalf("Cant read testdata directory contents: %s", err)
}
for _, f := range files {
if filepath.Ext(f.Name()) == ".xls" {
xlsfilename := f.Name()
xlsxfilename := strings.TrimSuffix(xlsfilename, filepath.Ext(xlsfilename)) + ".xlsx"
err := CompareXlsXlsx(path.Join(testdatapath, xlsfilename),
path.Join(testdatapath, xlsxfilename))
if err != "" {
t.Fatalf("XLS file %s an XLSX file are not equal: %s", xlsfilename, err)
}
}
}
}

BIN
testdata/bigtable.xls vendored

Binary file not shown.

BIN
testdata/bigtable.xlsx vendored

Binary file not shown.

BIN
testdata/float.xls vendored

Binary file not shown.

BIN
testdata/float.xlsx vendored

Binary file not shown.

BIN
testdata/issue47.xls vendored

Binary file not shown.

BIN
testdata/issue47.xlsx vendored

Binary file not shown.

BIN
testdata/negatives.xls vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
testdata/times.xls vendored

Binary file not shown.

BIN
testdata/times.xlsx vendored

Binary file not shown.