On 9 Jul 2021, at 9:58, 'Xavier Morel' via openpyxl-users wrote:
Cells have a
data_type
attribute which contains a typecode, however the
symbolic names (constants) for those typecodes are apparently private as
they got moved around a while back with a note that they're "only used
internally":https://foss.heptapod.net/openpyxl/openpyxl/-/commit/d46a102dabcde1410d7f16f16f445a40b8ec6d15
so relying on them seems... iffy.
Openpyxl itself relies generally on Python types, the data type values are used only when going to and from XML and you can overwrite them if you like: some times this is necessary.
These also seem to be mentioned pretty much nowhere outside of the
extracted APIDoc, and they're not exactly brimming with docstrings.
That's because I'm not a huge fan of docstrings: they're difficult to test and keep up to date: unit tests are much more useful.
Thus what is the correct way to know if a cell is a formula, or an error
when opening in data_only mode? Using the typecodes anyway? Using the
constants and handling the move if necessary? Other?
In data-only mode there will never be any formulae, cells marked as errors will contain the relevant error code.
Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Waldlehne 23
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226
Cells have a
data_type
attribute which contains a typecode, however the
symbolic names (constants) for those typecodes are apparently private as
they got moved around a while back with a note that they're "only used
internally":https://foss.heptapod.net/openpyxl/openpyxl/-/commit/d46a102dabcde1410d7f16f16f445a40b8ec6d15
so relying on them seems... iffy.
Openpyxl itself relies generally on Python types, the data type values are used only when going to and from XML and you can overwrite them if you like: some times this is necessary.
These also seem to be mentioned pretty much nowhere outside of the
extracted APIDoc, and they're not exactly brimming with docstrings.That's because I'm not a huge fan of docstrings: they're difficult to test and keep up to date: unit tests are much more useful.
Thus what is the correct way to know if a cell is a formula, or an error
when opening in data_only mode? Using the typecodes anyway? Using the
constants and handling the move if necessary? Other?In data-only mode there will never be any formulae, cells marked as errors will contain the relevant error code.