当前位置:网站首页>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();
}
边栏推荐
- Explanation of parallel search set theory and code implementation
- Light up the running light, rough notes for beginners (1)
- Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
- Oracle-触发器和程序包
- Simple operation of nixie tube (keil5)
- Shadowless cloud desktop - online computer
- NSIS search folder
- Butterfly theme beautification - Page frosted glass effect
- How can Oracle SQL statements modify fields that are not allowed to be null to allow nulls?
- SQL JOINS
猜你喜欢
Shadowless cloud desktop - online computer
Graduation thesis project local deployment practice
DelayQueue延迟队列的使用和场景
Play with grpc - go deep into concepts and principles
Rough notes of C language (2) -- constants
Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
Using GEE plug-in in QGIS
II Simple NSIS installation package
CADD course learning (6) -- obtain the existing virtual compound library (drugbank, zinc)
随机推荐
Simple operation of running water lamp (keil5)
Leetcode solution - number of islands
R language learning notes 1
Basic knowledge of public security -- FB
目标检测系列——Faster R-CNN原理详解
大学生活的自我总结-大一
Line test -- data analysis -- FB -- teacher Gao Zhao
Detailed explanation of miracast Technology (I): Wi Fi display
DelayQueue延迟队列的使用和场景
611. Number of effective triangles
The problem of configuring opencv in qt5.13.2 is solved in detail
Rough notes of C language (1)
[idea] common shortcut keys
氫氧化鈉是什麼?
Pit record of Chmod 2 options in deepin
NSIS finds out whether the file exists and sets the installation path
Course learning accumulation ppt
Set theory of Discrete Mathematics (I)
NPM and package common commands
Light up the running light, rough notes for beginners (1)