Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is lost while extracting data from xls #31

Closed
ismailzakky opened this issue Mar 12, 2018 · 1 comment
Closed

Data is lost while extracting data from xls #31

ismailzakky opened this issue Mar 12, 2018 · 1 comment

Comments

@ismailzakky
Copy link

i have 12000 rows data in xls file, i want to read parse, and insert those data to database.
but some data are different/lost from the actual data from excel.

this is my readXlsFile method :

func readXLSFile(filename string) ([][]string, error) {
	result := [][]string{}

	log.Println("Get into readXlsFile")

	xlFile, err := xls.Open(filename, "utf-8")
	if err != nil {
		return nil, err
	}

	sheet1 := xlFile.GetSheet(0)
	//str := ""
	log.Println("Max Row ", int(sheet1.MaxRow))
	for i := 0; i <= (int(sheet1.MaxRow)); i++ {
		row1 := sheet1.Row(i)
		temp := []string{}
		for j := 0; j <= int(row1.LastCol()); j++ {
			temp = append(temp, row1.Col(j))

			log.Println("Max Col", int(row1.LastCol()), "Of row ", i+1)
			//str += fmt.Sprintf("column %d data = %s ", j+1, row1.Col(j))
		}
		//log.Printf("row %d data : %s \n", i+1, str)
		//str = ""
		result = append(result, temp)
	}

	return result, nil
}

and here is my log that show the different data from my xls file :

2018/03/12 19:24:24 service.inquiry.go:4557: row 1836 data : column 1 data = :61:171218C59000NMSC column 2 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1837 data : column 1 data = :86: column 2 data =  column 3 data =  column 4 data =  column 5 data =  column 6 data =  column 7 data =  column 8 data =  column 9 data =  column 10 data =  column 11 data =  column 12 data = PLS10299 column 13 data =  column 14 data = 22162- column 15 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1838 data : column 1 data = :61:171218D300NMSC column 2 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1839 data : column 1 data = :86: column 2 data =  column 3 data =  column 4 data =  column 5 data =  column 6 data =  column 7 data =  column 8 data =  column 9 data =  column 10 data =  column 11 data =  column 12 data = PLS10299 column 13 data =  column 14 data = 22162- column 15 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1840 data : column 1 data = :61:171218D700NMSC column 2 data =   
2018/03/12 19:24:24 service.inquiry.go:4557: row 1841 data : column 1 data = :86: column 2 data =  column 3 data =  column 4 data =  column 5 data =  column 6 data =  column 7 data =  column 8 data =  column 9 data =  column 10 data =  column 11 data =  column 12 data = PLS10299 column 13 data =  column 14 data = 22162- column 15 data =   

and this is the actual data from xls file :
image

does anybody know why is this happening, and how to fix it?

@sergeilem
Copy link
Contributor

sergeilem commented Aug 14, 2018

extrame added a commit that referenced this issue Apr 26, 2020
FIX: data corruption while reading, issues #31 #46 #47
John-Saxon pushed a commit to John-Saxon/xls that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants