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

Paging is set when row/column cell merge is set at the same time, missing some cell data #315

Closed
xjxl520303 opened this issue Apr 7, 2024 · 2 comments

Comments

@xjxl520303
Copy link

Describe the bug

When I set row auto merge and the column 2 auto merge, then set pagination, I found some separated page item missing the data same as last page's last row or column or multiple r/c.

To Reproduce

here is the code

package main

import (
	"fmt"
	"os"

	"github.com/jedib0t/go-pretty/v6/table"
	"github.com/xuri/excelize/v2"
)

func main() {
	f, err := excelize.OpenFile("E:\\ExcelDemo\\titanic.xlsx")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer func() {
		if err := f.Close(); err != nil {
			fmt.Println(err)
		}
	}()
	rows, err := f.GetRows("titanic")
	if err != nil {
		fmt.Println(err)
		return
	}

	rowConfigAutoMerge := table.RowConfig{AutoMerge: true}
	t := table.NewWriter()
	t.SetOutputMirror(os.Stdout)

	tableHeader := make(table.Row, 0)
	for _, cell := range rows[0] {
		tableHeader = append(tableHeader, cell)
	}
	t.AppendHeader(tableHeader, rowConfigAutoMerge)

	for _, row := range rows[1:10] {
		innerRow := make(table.Row, 0)
		for _, cell := range row {
			innerRow = append(innerRow, cell)
		}
		t.AppendRow(innerRow, rowConfigAutoMerge)
		t.AppendSeparator()
	}
	t.SetColumnConfigs([]table.ColumnConfig{
		{Number: 2, AutoMerge: true},
	})
	t.SetPageSize(3)
	t.Render()
}

Screenshots

  1. original excel data screenshot.

image

  1. without pagination result screenshot.

image

  1. unexpected result screenshot.

image

Software (please complete the following information):

  • OS: Windows 11
  • GoLang Version 1.22
@jedib0t
Copy link
Owner

jedib0t commented Apr 7, 2024

Paging and auto-merge has never been tested. 😭

I'll take a look at this as soon as I can.

@jedib0t
Copy link
Owner

jedib0t commented Apr 8, 2024

@xjxl520303 check https://github.com/jedib0t/go-pretty/releases/tag/v6.5.8 --- this should fix it.

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