-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
XSSFWorkbook.SetForceFormulaRecalculation
will not force recalc on open Excel book
#1148
Comments
What do you exactly mean it's not working as expected? I checked both files (SetNameTaro-With-fullCalcOnLoad.xlsx and SetNameTaro-Without-fullCalcOnLoad.xlsx and what I see in the Microsoft Office are same - the formula is evaluated automatically. Btw, which version of NPOI are you using? |
I don't know why, but the occurrence of this problem is probabilistic. Not 100%. Around 30% ~ 50%? 1148.mp4 |
I have found this issue when I use NPOI latest |
And my unit test code ( [Test]
public void TestSetForceFormulaRecalculation()
{
XSSFWorkbook wb = new XSSFWorkbook(new MemoryStream(File.ReadAllBytes(@"C:\A\base.xlsx")));
wb.SetForceFormulaRecalculation(true);
var sheet = wb.GetSheet("Sheet1");
sheet.GetRow(0).GetCell(1).SetCellValue("Taro");
var stream = new MemoryStream();
wb.Write(stream);
File.WriteAllBytes(@"C:\A\SetNameTaro-Without-fullCalcOnLoad.xlsx", stream.ToArray());
} |
What is your purpose of calling POI docs:
|
In my case, there was an error when I tried
This didn't behave like Excel did. But I have no intension to offend about this. This will be compatibility problem and should take some while to deal with. [Test]
public void TestEvaluateAll()
{
XSSFWorkbook wb = new XSSFWorkbook(new MemoryStream(File.ReadAllBytes(@"C:\A\Zip.xlsx")));
wb.SetForceFormulaRecalculation(true);
var name = wb.GetName("〒");
var cr = new CellReference(name.RefersToFormula);
wb.GetSheet(name.SheetName).GetRow(cr.Row).GetCell(cr.Col).SetCellValue("123-456");
wb.GetCreationHelper().CreateFormulaEvaluator().EvaluateAll();
var stream = new MemoryStream();
wb.Write(stream);
File.WriteAllBytes(@"C:\A\SetZipTo123456-Without-fullCalcOnLoad.xlsx", stream.ToArray());
}
|
It is likely that the name Please try this |
Can you try a English name for the defined name instead of Japanese character? I'm thinking it can be a Unicode problem in the regular expression used to parse formula. |
Is it possible it's a bug in the Microsoft Office you used? Because if it's fully not working, perhaps it's NPOI's problem and the problem of the file generated. If partially working, it can be a bug of Microsoft Office. What version of Microsoft Office are you using? Office 365? |
Yes, finally, I had selected to replace the name Because both obsoleted EPPlus and NPOI rejected this mark as a named range.
|
I have used Excel 2013 with a perpetual license. |
I have decided to post a suggest openxml - Set xlsx to recalculate formulae on open - Stack Overflow
However it is your discretion to use it or not. |
I want to generate invoice xlsx using NPOI.
The invoice is not fully built by NPOI.
I use a hand made xlsx as a template.
Because it assumes that book is modified by software, there is sheet to hold variables.
The variables are just cells having names.
The issue is that in this way I need to use
XSSFWorkbook.SetForceFormulaRecalculation = true;
But this doesn't work as expected.
I'll post simple xlsx files for this repro:
Base.xlsx
SetNameTaro-With-fullCalcOnLoad.xlsx
SetNameTaro-Without-fullCalcOnLoad.xlsx
If
fullCalcOnLoad = true
is activated around:npoi/ooxml/XSSF/UserModel/XSSFWorkbook.cs
Line 2303 in b4b94fe
XSSFWorkbook.SetForceFormulaRecalculation
will work as expected.So I want to ask to add
fullCalcOnLoad = value
line to the NPOI.The text was updated successfully, but these errors were encountered: