Improve html rich text support

If contains only one text fragment with format, then it should be plain
text. And the format should be considered as Cell format
This commit is contained in:
Debao Zhang
2014-01-10 10:31:28 +08:00
parent 73a270d8c6
commit 461f05281e
2 changed files with 5 additions and 0 deletions
+3
View File
@@ -27,6 +27,9 @@ int main()
xlsx.workbook()->setHtmlToRichStringEnabled(true); xlsx.workbook()->setHtmlToRichStringEnabled(true);
xlsx.write("B4", "<b>Hello</b> <font color=\"red\">Qt</font> <i>Xlsx</i>"); xlsx.write("B4", "<b>Hello</b> <font color=\"red\">Qt</font> <i>Xlsx</i>");
xlsx.write("B6", "<font color=\"red\"><b><u><i>Qt Xlsx</i></u></b></font>");
//![1] //![1]
//![2] //![2]
+2
View File
@@ -621,6 +621,8 @@ int Worksheet::writeString(int row, int column, const RichString &value, const F
d->sharedStrings()->addSharedString(value); d->sharedStrings()->addSharedString(value);
Format fmt = format.isValid() ? format : d->cellFormat(row, column); Format fmt = format.isValid() ? format : d->cellFormat(row, column);
if (value.fragmentCount() == 1 && value.fragmentFormat(0).isValid())
fmt.mergeFormat(value.fragmentFormat(0));
d->workbook->styles()->addXfFormat(fmt); d->workbook->styles()->addXfFormat(fmt);
QSharedPointer<Cell> cell = QSharedPointer<Cell>(new Cell(value.toPlainString(), Cell::String, fmt, this)); QSharedPointer<Cell> cell = QSharedPointer<Cell>(new Cell(value.toPlainString(), Cell::String, fmt, this));
cell->d_ptr->richString = value; cell->d_ptr->richString = value;