QtXlsxWriter icon indicating copy to clipboard operation
QtXlsxWriter copied to clipboard

XLSX lib richtext

Open staubli-74210 opened this issue 4 years ago • 0 comments

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:

  • xlsxcell.h const RichString *richString() const;

  • xlsxcell.cpp const RichString *Cell::richString() const { Q_D(const Cell); if (isRichString()) return &d->richString; return NULL; }

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 ?

staubli-74210 avatar Sep 02 '20 16:09 staubli-74210