dbzhang800 / QtXlsxWriter

.xlsx file reader and writer for Qt5
http://qtxlsx.debao.me
Other
1.23k stars 631 forks source link

XLSX lib richtext #199

Open staubli-74210 opened 4 years ago

staubli-74210 commented 4 years ago

I had a .xlsx file to read. The file contains Japanese cells. I was surprised to read more characters that what was displayed by Excel. I dived into library code and discovered that the extra characters are phonetic attributes of the cell. unfortunately, xlsx lib handles the cell content as a RichSring class, with 2 QStrings in fragmentTexts field, and concatenates the 2 strings in the value() return QString. This is not what is expected. Furthermore, class Cell (http://qtxlsx.debao.me/cell.html) has a method to check if the cell is RichString but provides no method to get the values. I modified the class Cell as folows:

And could read the right cell content like this:

    Cell *cell= xlsx->cellAt(l,c);
    if (cell) {
        if (cell->isRichString()) {
            return cell->richString()->fragmentText(0);

...

What is your opinion ?