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

AVERAGEIF formula doesn't work in xls #1327

Closed
1 of 5 tasks
mferraricloudsurfers opened this issue May 2, 2024 · 7 comments
Closed
1 of 5 tasks

AVERAGEIF formula doesn't work in xls #1327

mferraricloudsurfers opened this issue May 2, 2024 · 7 comments

Comments

@mferraricloudsurfers
Copy link

mferraricloudsurfers commented May 2, 2024

NPOI Version

2.7.0

File Type

  • XLSX
  • XLS
  • DOCX
  • XLSM
  • OTHER

NPOI File

5f88c7e2-e3d7-4594-a8a6-f8d17516f177.xls

Reproduce Steps

Issue Description

var fs = new FileStream(file, FileMode.Create, FileAccess.Write)
IWorkbook workbook = new HSSFWorkbook();
IRow row = excelSheet.CreateRow(0);
row.CreateCell(1).SetCellFormula($"SUM(B5:B10)");
row.CreateCell(2).SetCellFormula($"AVERAGEIF(B5:B10,\"<> 0\")");
workbook.Write(fs);
fs.Close();

Opening the result xls file with Microsoft® Excel® per Microsoft 365 MSO (Version 2403 Build 16.0.17425.20176) 64 bit (Italian), the SUM formula is correctly translated and works. Instead, AVERAGEIF is not translated and the cell is marked in Excel how error with #NAME not recognized.

image

@Bykiev
Copy link
Collaborator

Bykiev commented May 2, 2024

Can you please attach the Excel file produced by NPOI? In Excel file there shouldn't be any localized data

@mferraricloudsurfers
Copy link
Author

mferraricloudsurfers commented May 3, 2024

Opening the file in protected view mode, will display correctly the result

image

While, if I open the file in edit mode and I replace the "AVERAGEIF" with the corresponding localized command version, it works.

image

@Bykiev
Copy link
Collaborator

Bykiev commented May 3, 2024

can you please test with xlsx?

@mferraricloudsurfers
Copy link
Author

can you please test with xlsx?

it works with xlsx

@Bykiev
Copy link
Collaborator

Bykiev commented May 3, 2024

Seems to be a bug, I'll try to research it later

@tonyqus tonyqus added the xls label May 3, 2024
@tonyqus tonyqus changed the title AVERAGEIF formula missing translation AVERAGEIF formula doesn't work in xls May 3, 2024
@Bykiev
Copy link
Collaborator

Bykiev commented May 4, 2024

I did a research and AVERAGEIF formula is not supported by excel 97-2003, when you saving the workbook with MS Excel it warns that this function is not supported by versions prior 2007. When opening such file with MS Excel 2007+ it is opened in compatibility mode. I believe it's not supported by POI and the workbook always saved in EXCEL97 format for xls and it won't be fixed in NPOI.

@tonyqus, what do you think?

@tonyqus
Copy link
Member

tonyqus commented May 6, 2024

Since AverageIf function is not supported in Old Excel 97-2003, this bug is invalid.

@tonyqus tonyqus closed this as completed May 6, 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

3 participants