Comments (5)
Hi, this is an intended behavior. As you can see,
When you call xlsx.write("A1", "=1+2"); to generate a xlsx file, it make sense to let xlsx.read("A1") return the formula itself.
Another problem to return the value instead of the formula is that, you must use sheet.writeFormula("A1", "=1+2", Format(), 3) to generate a xlsx file which contains proper formula result. In normal case, 0 is written to the xlsx file as the formula result, the proper value will be generated by Excel or OpenOffice when you open the xlsx file.
However, if your .xlsx file contains proper values, you can use xlsx.cellAt("A1").value() to extract the cell value contents, and xlsx.cellAt("A1").formula() to extract the formula contents.
from qtxlsxwriter.
Got it. Funny I was using that method prior.
Thank you
from qtxlsxwriter.
I remembered why I switched away from this call. If the cell is empty it returns a NULL value but if you run sheet->cellAt(x,y)->value().toString() you get a segFault. So in order to avoid this you have to query the sheet->cellAt(x,y) twice. As a feature request I would say it may be better for this to return a empty string in these cases, might you agree?
QString val;
if (sheet->cellAt(x,y) != NULL){ val.append(sheet->cellAt(x,y)->value().toString();) }
else { val.append(""); }
from qtxlsxwriter.
Hi, you can write a helper function if it is used many times in your code.
QString getCellString(Document *xlsx, int row, int col)
{
Cell *cell = xlsx.cellAt(row, col);
if (cell)
return cell->value().toString();
else
return QString();
}
What you expected is that, when you try to access a not-exist cell, QtXlsx create a Blank cell which contains a Null string, then returns the cell for you. But I don't like this behavior.
As you can see, non-exsts-cell != blank-cell, for example, if you have a xlsx file which created by
xlsx.write("B2", QVariant());
Then you can get a null string through
xlsx.cellAt("B2").value().toString();
But you will get a null cell if that cell doesn't exist
xlsx.cellAt("C3"); //zero here.
Maybe we can add an additional param for the read() function, such as
xlsx.read("C3", Cell::RealValue);
or
xlsx.stringValue("C3");
Also, please note that, null-string != empty-string. For example, you add an empty but not null string through
val.append("")
but following code create a null string.
val.append(QString())
from qtxlsxwriter.
I think your idea of adding stringValue() would be a great idea and probably solve my issue with date formats.
Thank you for the null value comment.
from qtxlsxwriter.
Related Issues (20)
- How to write data in batches HOT 1
- 如何设置纸张方向的横向和纵向? HOT 1
- how to use CellRange with import and export together
- Save to pdf
- examples Chart::CT_Line
- How to setup Qtxlsxwriter
- Very good
- Building QtXlsxWriter with Qt using android kit HOT 1
- How to delete row or column
- Ask for a new release (0.3.1) with the LICENSE file HOT 4
- Unable to determine byte order HOT 2
- mingw32-make error HOT 1
- Save with protection On and password
- How put the color in chart with Xlsx
- Build in mingw32
- 这个库有一些bug
- why Workbook::copySheet always returns false ?
- 使用库后,VS报已在****.exe 中执行断点指令(__debugbreak()语句或类似调用)。
- 如何冻结sheet的前几行?
- Error when delete sheet
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 qtxlsxwriter.