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

When moving a row up in HSSFWorkbook, the LastRowNum decreases, but the physical rows do not decrease. #1424

Open
1 task done
yoi102 opened this issue Sep 26, 2024 · 0 comments

Comments

@yoi102
Copy link

yoi102 commented Sep 26, 2024

NPOI Version

2.7.1

File Type

  • XLS

Upload the Excel File

input.xls

Reproduce Steps

string inputFile = "input.xls";
IWorkbook workbook;

using (FileStream file = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
    workbook = new HSSFWorkbook(file);
}


ISheet sheet = workbook.GetSheetAt(0);

Console.WriteLine(sheet.LastRowNum);
Console.WriteLine(sheet.PhysicalNumberOfRows);

sheet.ShiftRows(3, sheet.LastRowNum, -1);

Console.WriteLine(sheet.LastRowNum);
Console.WriteLine(sheet.PhysicalNumberOfRows);

string outputFile = "output.xls";
using (FileStream file = new FileStream(outputFile, FileMode.Create, FileAccess.Write))
{
    workbook.Write(file);
}

Issue Description

As shown in the code above, after I moved all rows below the third row up by one, the sheet.LastRowNum decreased by 1, but the sheet.PhysicalNumberOfRows remained unchanged.
Unlike XSSFWorkbook, where both sheet.LastRowNum and sheet.PhysicalNumberOfRows decrease by 1.

image

@yoi102 yoi102 added the bug label Sep 26, 2024
@tonyqus tonyqus added the xls label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants