当前位置:网站首页>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();
}
边栏推荐
- Eclipse project recompile, clear cache
- How to delete the virus of inserting USB flash disk copy of shortcut to
- Web page Chinese display (print, etc.) GBK error, solution, software
- Mouse click fireworks explosion effect
- The folder directly enters CMD mode, with the same folder location
- 使用go语言读取txt文件写入excel中
- Self summary of college life - freshman
- SQL JOINS
- The SQL implementation has multiple records with the same ID, and the latest one is taken
- Apple script
猜你喜欢
Word import literature -mendeley
2022年PMP项目管理考试敏捷知识点(7)
611. 有效三角形的个数
Play with grpc - go deep into concepts and principles
Hdu1232 unimpeded project (and collection)
arcgis_ spatialjoin
Graduation thesis project local deployment practice
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
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
611. Number of effective triangles
随机推荐
Rough notes of C language (2) -- constants
static的作用
R language learning notes 1
Oracle code use
Leetcode solution - number of islands
Set theory of Discrete Mathematics (I)
Today, share the wonderful and beautiful theme of idea + website address
What is Bezier curve? How to draw third-order Bezier curve with canvas?
How to modify the file path of Jupiter notebook under miniconda
Apple input method optimization
I implement queue with C I
Apple system shortcut key usage
Selenium element positioning
D2L installation
Ugnx12.0 initialization crash, initialization error (-15)
QT small case "addition calculator"
CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)
[neo4j] common operations of neo4j cypher and py2neo
Idea common settings
Process (P) runs, and idle is different from pycharm