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

write data by streamwriter but the file has some problem #1202

Closed
Crearns opened this issue Apr 9, 2022 · 5 comments
Closed

write data by streamwriter but the file has some problem #1202

Crearns opened this issue Apr 9, 2022 · 5 comments
Labels
wontfix This will not be worked on

Comments

@Crearns
Copy link

Crearns commented Apr 9, 2022

Description

Steps to reproduce the issue:
1.
2.
3.

Describe the results you received:
I wrote some data by streamwirter,and the row data is no order, the result is that the output file has some problem
image

here is my code

func main() {
	var (
		err  error
		data []interface{}
	)
	file := excelize.NewFile()
	writer, err := file.NewStreamWriter("Sheet1")
	if err != nil {
		return
	}
	//
	d := []interface{}{"A", "B", "C", "D", "E", "F", "G"}
	err = writer.SetRow("A1", d)
	if err != nil {
		return
	}

	data = []interface{}{"A1", "B1", "C1", "D1", "E1", "F1"}
	err = writer.SetRow("A2", data)
	if err != nil {
		return
	}

	data = []interface{}{"A2", "B2", "C2", "D2", "E2", "F2"}
	err = writer.SetRow("A3", data)
	if err != nil {
		return
	}

	data = []interface{}{"A3", "B3", "C3", "D3", "E3", "F3"}
	err = writer.SetRow("A4", data)
	if err != nil {
		return
	}

        // back to the second row and write the data G2
	err = writer.SetRow("G2", []interface{}{"G2"})
	if err != nil {
		return
	}

	err = writer.Flush()
	if err != nil {
		return
	}

	err = file.SaveAs("/Users/cc/Desktop/test2.xlsx")
	if err != nil {
		return
	}
}

Describe the results you expected:

Output of go version:

go version go1.16.5 darwin/amd64

Excelize version or commit ID:

github.com/xuri/excelize/v2 v2.4.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Microsoft Excel™ 16.59
macOS 12.1
2019 MacBook Pro 16 inch

@xuri
Copy link
Member

xuri commented Apr 9, 2022

Thanks for your issue. Note that as the document says, please ensure that the order of line numbers is ascending in the streaming writing process.

@xuri xuri added the wontfix This will not be worked on label Apr 9, 2022
@Crearns
Copy link
Author

Crearns commented Apr 9, 2022

Thanks for your issue. Note that as the document says, please ensure that the order of line numbers is ascending in the streaming writing process.

Although the line numbers are not in order, the data written is not in conflict, is this not allowed?

@xuri
Copy link
Member

xuri commented Apr 9, 2022

Yep, if you wanna write cell back around, please using the normal API.

@Crearns
Copy link
Author

Crearns commented Apr 11, 2022

Yep, if you wanna write cell back around, please using the normal API.

ok, thanks

@xuri xuri closed this as completed Apr 11, 2022
@xuri
Copy link
Member

xuri commented Apr 11, 2022

I closed this issue. If you have any questions, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants