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 result not expected #312

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

Paging result not expected #312

xjxl520303 opened this issue Apr 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@xjxl520303
Copy link

Describe the bug
When using t.SetPageSize() method, the result page size and page number not right, and even show me some empty row data.

To Reproduce

Download Titanic data and convert to .xlsx, and saved to disk, then using Go Excelize lib to open and read some line, set paging.

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
	}

	t := table.NewWriter()
	t.SetOutputMirror(os.Stdout)

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

	for _, row := range rows[1:7] {
		innerRow := make(table.Row, 0)
		for _, cell := range row {
			innerRow = append(innerRow, cell)
		}
		t.AppendRow(innerRow)
		t.AppendSeparator()
	}
	t.SetPageSize(2)
	t.Render()
}

Screenshots
企业微信截图_171212629498

Software (please complete the following information):

  • OS: Windows
  • GoLang Version: 1.22.1
@jedib0t jedib0t added the bug Something isn't working label Apr 5, 2024
@jedib0t jedib0t closed this as completed in d03b448 Apr 5, 2024
@jedib0t
Copy link
Owner

jedib0t commented Apr 5, 2024

Hey @xjxl520303 thanks for identifying and reporting this bug in a easy-to-reproduce manner. Appreciate the details! 👍🏽

I've fixed this bug in https://github.com/jedib0t/go-pretty/releases/tag/v6.5.7 --- please try and let me know.

Just FYI, the issue was related to manually adding Separators with Paging.

@xjxl520303
Copy link
Author

@jedib0t tky fixed the bug, here is another bug I found #315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants