Comments (3)
Apparently you do have to evaluate a workbook before saving it to get those value nodes created. Here's the code I used:
var evaluator = new XSSFFormulaEvaluator( _workbook );
evaluator.EvaluateAll();
worked like a charm.
from npoi.
I'm going to share anything interesting I find from doing a diff on the text/xml versions of the two files (the one which doesn't display the values in formula cells and one which does).
-
Content_Types.xml - diff reports the files are encoded differently, the original (created by NPOI) being UTF-8 encoded but without a signature (whatever that is). The version saved by Excel has a signature.
-
Same lack of signature on _rels/.rels
-
docProps/app.xml (I had to reformat the Excel-written file because it was not indented): Minor changes, mostly related to where various things show up as nodes and attributes
-
docProps/core.xml (this time I had to reformat the NPOI created file): The corProperties node in the NPOI version appears to be missing this attribute:
xmlns:dcmitype="http://purl.org/dc/dcmitype/"
- docProps/custom.xml: Certain property nodes have different values:
From the NPOI version:
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Generator">
<lpwstr xmlns="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">NPOI</lpwstr>
</property>
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="Generator Version">
<lpwstr xmlns="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">2.7.0</lpwstr>
</property>
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Generator">
<vt:lpwstr>NPOI</vt:lpwstr>
</property>
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="Generator Version">
<vt:lpwstr>2.7.0</vt:lpwstr>
</property>
- xl/worksheets/sheet2.xml (I had to reformat both files -- and I should've started here first, as this contains the actual spreadsheet data).
Some interesting differences in the formula cells. First, here's what NPOI wrote:
<row r="981" spans="1:27" ht="17.5" x14ac:dyDescent="0.35">
<c r="H981" s="351">
<f dt2D="0" dtr="0">sum(I973:I977)</f>
<v/>
</c>
<c r="I981" s="353">
<f dt2D="0" dtr="0">sum(I973:I977)</f>
<v/>
</c>
And here's what Excel saved the file as:
<row r="981" spans="1:27" ht="17.5" x14ac:dyDescent="0.45">
<c r="H981" s="9">
<f>SUM(I973:I977)</f>
<v>77.759999999999991</v>
</c>
<c r="I981" s="11">
<f>SUM(I973:I977)</f>
<v>77.759999999999991</v>
</c>
The Excel-written file does not include the dt2D="0" dtr="0" attribute in the nodes. More importantly, the v nodes in the NPOI-written file are empty. I presume v stands for value, i.e., the cell's value.
Is maybe the problem that I have to have NPOI do a recalc or something before saving the file? Or do I have to calculate the value myself and store that as well as the formula?
from npoi.
The Excel-written file does not include the dt2D="0" dtr="0" attribute in the nodes. More importantly, the v nodes in the NPOI-written file are empty. I presume v stands for value, i.e., the cell's value.
Please use 2.6.2 version for now. 2.7.0 have a regression bug #1315
Let me know if it works after switching back to 2.6.2
from npoi.
Related Issues (20)
- Formula openxml gets corrupted after opened and saved by NPOI 2.7.0 HOT 12
- Excel file is always modified even if only opened for reading HOT 1
- Can't copy sheet's chart when using sheet copy function HOT 1
- System.Runtime.CompilerServices.Unsafe 4.0.41 not found while calling AsSpan HOT 13
- TypeLoadException: “NPOI.XSSF.UserModel.XSSFSheet.RemoveDataValidation” hasn't been implemented in “NPOI.OOXML, Version=2.7.0.0," HOT 1
- Add API for SearchText for xlsx,xls HOT 4
- Reading large files HOT 3
- AVERAGEIF formula doesn't work in xls HOT 7
- XWPF POI Bug Migration II
- How can set picture properties on "Move and size with cells" HOT 2
- XSSFSheet.CopySheet doesn't support cloning charts
- i cannot open a file with npoi HOT 5
- The npoi package conflicts with the Magicodes.IE package HOT 2
- 'Object reference not set to an instance of an object' in XSSFCell.ToString() HOT 4
- npoi will inexplicably digitize some cells with formulas HOT 5
- excel file damaged after adding images and saving
- Unable to rotate image manually in DOCX
- Looking for a new job in Asia
- "Do you want us to try to recover as much as we can?" error message when opnening file when using 2.7.0 version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from npoi.