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

Read numeric cell precision issues #1523

Closed
ahKevinXy opened this issue Apr 18, 2023 · 12 comments
Closed

Read numeric cell precision issues #1523

ahKevinXy opened this issue Apr 18, 2023 · 12 comments
Labels
confirmed This issue can be reproduced

Comments

@ahKevinXy
Copy link

ahKevinXy commented Apr 18, 2023

Description
excel 读取的身份证号码的时候

excel 里面显示 正常

package main

import (
	"fmt"
	"github.com/xuri/excelize/v2"

	"time"
)

func main() {
	fileName := "1.xlsx"

	fmt.Println(fileName)

	fmt.Println(time.Now())
	files, err := excelize.OpenFile(fileName)
	if err != nil {
		return
	}
	name1 := files.GetSheetName(0)
	name2 := files.GetSheetName(1)
	name3 := files.GetSheetName(2)

	fmt.Println(name3, name2, name1, "这是一个名称")
	rows, err := files.GetRows("Sheet1")
	fmt.Println(err)
	for _, v := range rows {
		if v[0] == "李三" {
			fmt.Println(v[1])
		}
		if v[0] == "李四" {
			fmt.Println(v[1])
		}

	}
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err, "错误信息")
		}
	}()

}

Steps to reproduce the issue:

  1. 读取身份证号码的excel
  2. 随机性出现 精度失真 末尾出现0的现象
  3. excel 身份证号码是没有问题的

Describe the results you received:
读取 string的row 的cell 时候按理 不会出现 失真现象

Describe the results you expected:
出现了 尾数为 0000

Output of go version:
go version go1.18.3 darwin/amd64

8606114100

image

Excelize version or commit ID:

github.com/xuri/excelize/v2 v2.7.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):

@ahKevinXy
Copy link
Author

image

@xuri
Copy link
Member

xuri commented Apr 18, 2023

Thanks for your feedback. Could you follow the issue template, and show us a complete, standalone example program or reproducible demo?

@xuri xuri added the needs more info This issue can't reproduce, need more info label Apr 18, 2023
@xuri xuri changed the title 身份证号码精度失真 Read numeric cell precision issues Apr 18, 2023
@ahKevinXy
Copy link
Author

Thanks for your feedback. Could you follow the issue template, and show us a complete, standalone example program or reproducible demo?

这个是什么原因导致的

@ahKevinXy
Copy link
Author

ahKevinXy commented Apr 18, 2023

自己测试 2.5.0 版本没有问题,2.6.0 以后版本就出现这样精度问题了

@ahKevinXy
Copy link
Author

v2.6.0

image

@ahKevinXy
Copy link
Author

v2.5.0

image

@xuri
Copy link
Member

xuri commented Apr 18, 2023

Could you provide spreadsheet xlsx attachment without confidential info?

@ahKevinXy
Copy link
Author

Could you provide spreadsheet xlsx attachment without confidential info?

34.xlsx

@ahKevinXy
Copy link
Author

image

@ahKevinXy
Copy link
Author

image

@ahKevinXy
Copy link
Author

这边 是因为什么格式导致,我清空格式这个问题就解决了

@xuri xuri added confirmed This issue can be reproduced and removed needs more info This issue can't reproduce, need more info labels Apr 18, 2023
@xuri xuri closed this as completed in fb6ce60 Apr 18, 2023
@xuri
Copy link
Member

xuri commented Apr 18, 2023

Thanks for your feedback. I have fixed this issue. Please upgrade to the master branch code. This patch will be released in the next version.

xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
- Simplify variable declaration and error return statements
- Remove the internal `xlsxTabColor` data type
- Using the `xlsxColor` data type instead of `xlsxTabColor`
- Update unit test, improve code coverage
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Simplify variable declaration and error return statements
- Remove the internal `xlsxTabColor` data type
- Using the `xlsxColor` data type instead of `xlsxTabColor`
- Update unit test, improve code coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants