more date reading enhancements
This commit is contained in:
parent
47f24af084
commit
c849b3b45d
11
col.go
11
col.go
@ -58,11 +58,12 @@ func (xf *XfRk) String(wb *WorkBook) string {
|
||||
if formatterLower == "general" ||
|
||||
strings.Contains(formatter.str, "#") ||
|
||||
strings.Contains(formatter.str, ".00") ||
|
||||
strings.Contains(formatterLower, "mm/yy") ||
|
||||
strings.Contains(formatterLower, "dd/yy") ||
|
||||
strings.Contains(formatterLower, "mm.yy") ||
|
||||
strings.Contains(formatterLower, "dd.yy") ||
|
||||
strings.Contains(formatterLower, "дд.гг") {
|
||||
strings.Contains(formatterLower, "m/y") ||
|
||||
strings.Contains(formatterLower, "d/y") ||
|
||||
strings.Contains(formatterLower, "m.y") ||
|
||||
strings.Contains(formatterLower, "d.y") ||
|
||||
strings.Contains(formatterLower, "h:") ||
|
||||
strings.Contains(formatterLower, "д.г") {
|
||||
//If format contains # or .00 then this is a number
|
||||
return xf.Rk.String()
|
||||
} else {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
//Compares xls and xlsx files
|
||||
func compareXlsXlsx(xlsfilepathname string, xlsxfilepathname string) string {
|
||||
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)
|
||||
@ -27,8 +27,8 @@ func compareXlsXlsx(xlsfilepathname string, xlsxfilepathname string) string {
|
||||
for row, xlsxRow := range xlsxSheet.Rows {
|
||||
xlsRow := xlsSheet.Row(row)
|
||||
for cell, xlsxCell := range xlsxRow.Cells {
|
||||
xlsText := xlsRow.Col(cell)
|
||||
xlsxText := xlsxCell.String()
|
||||
xlsText := xlsRow.Col(cell)
|
||||
if xlsText != xlsxText {
|
||||
//try to convert to numbers
|
||||
xlsFloat, xlsErr := strconv.ParseFloat(xlsText, 64)
|
||||
|
@ -18,7 +18,7 @@ func TestIssue47(t *testing.T) {
|
||||
if filepath.Ext(f.Name()) == ".xls" {
|
||||
xlsfilename := f.Name()
|
||||
xlsxfilename := strings.TrimSuffix(xlsfilename, filepath.Ext(xlsfilename)) + ".xlsx"
|
||||
err := compareXlsXlsx(path.Join(testdatapath, xlsfilename),
|
||||
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/float.xls
vendored
Normal file
BIN
testdata/float.xls
vendored
Normal file
Binary file not shown.
BIN
testdata/float.xlsx
vendored
Normal file
BIN
testdata/float.xlsx
vendored
Normal file
Binary file not shown.
BIN
testdata/times.xls
vendored
Normal file
BIN
testdata/times.xls
vendored
Normal file
Binary file not shown.
BIN
testdata/times.xlsx
vendored
Normal file
BIN
testdata/times.xlsx
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user