当前位置:网站首页>Openxlsx field reading problem
Openxlsx field reading problem
2022-07-05 07:35:00 【sukhoi27smk】
In the reading excel I found that some fields cannot be read , Through the excel After decompressing the file, we found , Normal read and no
The fields that can be read normally are sharedString.xml The format stored in is different , Take one of the fields , Here's the picture :
Normally read

Unreadable


The difference can be seen by comparison , Then look for openxlsx Treatment of this piece , Find the following code by debugging the code :
const char* XLSharedStrings::getString(uint32_t index) const
{
auto iter = xmlDocument().document_element().children().begin();
std::advance(iter, index);
return iter->first_child().text().get();
}By analyzing the code context , And combine getString function , It is found that the contents of this field are stored in multiple subordinate nodes , Therefore, the above storage format cannot be processed , We got a problem , Just make a compatible , The modified code is as follows :
const char* XLSharedStrings::getString(uint32_t index) const
{
auto iter = xmlDocument().document_element().children().begin();
std::advance(iter, index);
static std::string t;
t = "";
t = iter->first_child().text().get();
pugi::xml_node iter_r = iter->first_child();
while (!iter_r.empty())
{
if (!strcmp(iter_r.name(), "r"))
{
pugi::xml_node iter_t = iter_r.first_child();
while (!iter_t.empty())
{
if (!strcmp(iter_t.name(), "t"))
{
t = t + iter_t.text().get();
}
iter_t = iter_t.next_sibling();
}
}
iter_r = iter_r.next_sibling();
}
return t.c_str();
}边栏推荐
- M2dgr slam data set of multi-source and multi scene ground robot
- Efficiency difference: the add method used by the set directly and the add method used by the set after judgment
- [MySQL] database knowledge record
- Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
- Close of office 365 reading
- Oracle code use
- deepin 20 kivy unable to get a window, abort
- CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
- Oracle-触发器和程序包
- Apple script
猜你喜欢

Hdu1232 unimpeded project (and collection)

SQL JOINS
![[idea] efficient plug-in save actions to improve your work efficiency](/img/6e/49037333964865d9900ddf5698f7e6.jpg)
[idea] efficient plug-in save actions to improve your work efficiency

Pagoda create multiple sites with one server

Butterfly theme beautification - Page frosted glass effect

M2dgr slam data set of multi-source and multi scene ground robot

大学生活的自我总结-大一

And let's play dynamic proxy (extreme depth version)

Deepin get file (folder) list

II Simple NSIS installation package
随机推荐
Matrix and TMB package version issues in R
The mutual realization of C L stack and queue in I
[MySQL] database knowledge record
Basic series of SHEL script (II) syntax + operation + judgment
Today, share the wonderful and beautiful theme of idea + website address
CADD course learning (6) -- obtain the existing virtual compound library (drugbank, zinc)
Ugnx12.0 initialization crash, initialization error (-15)
II Simple NSIS installation package
Oracle-触发器和程序包
[idea] efficient plug-in save actions to improve your work efficiency
Anaconda navigator click open no response, can not start error prompt attributeerror: 'STR' object has no attribute 'get‘
And play the little chestnut of dynamic agent
Delayqueue usage and scenarios of delay queue
Don't confuse the use difference between series / and / *
ModuleNotFoundError: No module named ‘picamera‘
纯碱是做什么的?
list. files: List the Files in a Directory/Folder
Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
Deepin get file (folder) list