当前位置:网站首页>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();
}
边栏推荐
- Idea push project to code cloud
- Mouse click fireworks explosion effect
- Cygwin installation
- Apple input method optimization
- The mutual realization of C L stack and queue in I
- CADD course learning (5) -- Construction of chemosynthesis structure with known target (ChemDraw)
- Butterfly theme beautification - Page frosted glass effect
- With the help of Navicat for MySQL software, the data of a database table in different or the same database link is copied to another database table
- [idea] efficient plug-in save actions to improve your work efficiency
- Using GEE plug-in in QGIS
猜你喜欢
Daily Practice:Codeforces Round #794 (Div. 2)(A~D)
And play the little chestnut of dynamic agent
Matrix and TMB package version issues in R
Self summary of college life - freshman
Microservice registry Nacos introduction
When jupyter notebook is encountered, erroe appears in the name and is not output after running, but an empty line of code is added downward, and [] is empty
Miracast技术详解(一):Wi-Fi Display
How to delete the virus of inserting USB flash disk copy of shortcut to
QT small case "addition calculator"
Word import literature -mendeley
随机推荐
Set theory of Discrete Mathematics (I)
Delayqueue usage and scenarios of delay queue
[neo4j] common operations of neo4j cypher and py2neo
Target detection series - detailed explanation of the principle of fast r-cnn
Rough notes of C language (2) -- constants
Ue5 hot update - remote server automatic download and version detection (simplehotupdate)
Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
Hdu1232 unimpeded project (and collection)
The problem of configuring opencv in qt5.13.2 is solved in detail
NSIS search folder
GBK error in web page Chinese display (print, etc.), solution
Import CV2, prompt importerror: libcblas so. 3: cannot open shared object file: No such file or directory
HDU1231 最大连续子序列(分治or动规or双指针)
Let me teach you how to develop a graphic editor
CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
Miracast技术详解(一):Wi-Fi Display
Professional knowledge of public security -- teacher bilitong
[idea] efficient plug-in save actions to improve your work efficiency
[MySQL] database knowledge record
QT small case "addition calculator"