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

InsertRow after stream writing is useless #826

Closed
eaglexiang opened this issue Apr 25, 2021 · 4 comments
Closed

InsertRow after stream writing is useless #826

eaglexiang opened this issue Apr 25, 2021 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@eaglexiang
Copy link
Contributor

Description

I tried to insert one empty row after stream writing a excel file, no new line was inserted.

By the way, result of insert operation after normal writing is correct.

Steps to reproduce the issue:

  1. create a new excel file by excelize
  2. create a stream writer and write some cells.
  3. flush stream writer and call method File.InsertRow
  4. save excel as file.
// empty line found at A1
package main

import "github.com/360EntSecGroup-Skylar/excelize/v2"

func main() {
	ef := excelize.NewFile()

	err := ef.SetCellDefault("Sheet1", "A1", "test")
	if err != nil {
		panic(err)
	}

	err = ef.InsertRow("Sheet1", 1)
	if err != nil {
		panic(err)
	}

	err = ef.SaveAs("test.xlsx")
	if err != nil {
		panic(err)
	}
}
// no empty line
package main

import "github.com/360EntSecGroup-Skylar/excelize/v2"

func main() {
	ef := excelize.NewFile()

	sw, err := ef.NewStreamWriter("Sheet1")
	if err != nil {
		panic(err)
	}

	err = sw.SetRow("A1", []interface{}{"test"})
	if err != nil {
		panic(err)
	}
	err = sw.Flush()
	if err != nil {
		panic(err)
	}

	err = ef.InsertRow("Sheet1", 1)
	if err != nil {
		panic(err)
	}

	err = ef.SaveAs("test.xlsx")
	if err != nil {
		panic(err)
	}
}

Describe the results you received:

one excel file filled with only my test data.

Describe the results you expected:

one excel file filled with my test data and one empty line.

Output of go version:

go version go1.16.3 linux/amd64

Excelize version or commit ID:

v2.4.0

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

LSB Version: n/a
Distributor ID: ManjaroLinux
Description: Manjaro Linux
Release: 21.0.2
Codename: Ornara

@xuri
Copy link
Member

xuri commented Apr 25, 2021

We can't use common API and stream API mixed, this issue is similar to issues #725 and #777.

@xuri xuri closed this as completed Apr 25, 2021
@xuri xuri added the duplicate This issue or pull request already exists label Apr 25, 2021
@eaglexiang
Copy link
Contributor Author

Okay, I can follow your api rules. However, I need a way to create a huge excel with headers, which is built with merged cells like:

| header0 |         header1      |
|         | --------- | -------- |
|         |  header2  |  header  |

What's the typical way?

@xuri
Copy link
Member

xuri commented Apr 26, 2021

The Excelize doesn't support merge cell in streaming mode currently, I'll add this feature recently.

@xuri xuri added the in progress Working in progress label Apr 27, 2021
@xuri
Copy link
Member

xuri commented Apr 28, 2021

Hi @eaglexiang, I have just support merge cell in streaming mode, please try to use the master branch code, and this feature will be released in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants