changeset 19:4ecb91aaf33f

Hack dataBar's without gradient This is a Microsoft extension and there is no built in support for this. We hardcode what we need here as this is enough for us.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 30 Mar 2016 16:56:05 +0200
parents 4f679f613e91
children df7936065450
files src/xlsx/xlsxconditionalformatting.cpp
diffstat 1 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/xlsx/xlsxconditionalformatting.cpp	Tue Mar 22 17:53:56 2016 +0100
+++ b/src/xlsx/xlsxconditionalformatting.cpp	Wed Mar 30 16:56:05 2016 +0200
@@ -662,6 +662,9 @@
         sqref.append(range.toString());
     writer.writeAttribute(QStringLiteral("sqref"), sqref.join(QLatin1Char(' ')));
 
+    const QString extNS = QStringLiteral("http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
+    const QString xmNS = QStringLiteral("http://schemas.microsoft.com/office/excel/2006/main");
+
     for (int i=0; i<d->cfRules.size(); ++i) {
         const QSharedPointer<XlsxCfRuleData> &rule = d->cfRules[i];
         writer.writeStartElement(QStringLiteral("cfRule"));
@@ -698,6 +701,16 @@
             d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo2].value<XlsxCfVoData>());
             rule->attrs[XlsxCfRuleData::A_color1].value<XlsxColor>().saveToXml(writer);
             writer.writeEndElement();//dataBar
+            writer.writeStartElement(QStringLiteral("extLst"));
+            writer.writeStartElement(QStringLiteral("ext"));
+            writer.writeNamespace(extNS, QStringLiteral("x14"));
+            writer.writeAttribute(QStringLiteral("uri"),
+                                  QStringLiteral("{B025F937-C7B1-47D3-B67F-A62EFF666E3E}"));
+            writer.writeStartElement(extNS, QStringLiteral("id"));
+            writer.writeCharacters(QStringLiteral("{00000000-000E-0000-0000-000001000000}"));
+            writer.writeEndElement(); //id
+            writer.writeEndElement(); //ext
+            writer.writeEndElement(); //extLst
         } else if (rule->attrs[XlsxCfRuleData::A_type] == QLatin1String("colorScale")) {
             writer.writeStartElement(QStringLiteral("colorScale"));
             d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
@@ -729,6 +742,46 @@
     }
 
     writer.writeEndElement(); //conditionalFormatting
+    writer.writeStartElement(QStringLiteral("extLst"));
+    writer.writeStartElement(QStringLiteral("ext"));
+    writer.writeNamespace(extNS, QStringLiteral("x14"));
+    writer.writeAttribute(QStringLiteral("uri"),
+                          QStringLiteral("{78C0D931-6437-407d-A8EE-F0AAD7539E65}"));
+    writer.writeStartElement(extNS, QStringLiteral("conditionalFormattings"));
+    writer.writeStartElement(extNS, QStringLiteral("conditionalFormatting"));
+    writer.writeNamespace(xmNS, QStringLiteral("xm"));
+    writer.writeStartElement(extNS, QStringLiteral("cfRule"));
+    writer.writeAttribute("type", "dataBar");
+    writer.writeAttribute("id", "{00000000-000E-0000-0000-000001000000}");
+    writer.writeStartElement(extNS, "dataBar");
+    writer.writeAttribute("gradient", "0");
+    writer.writeAttribute("negativeBarColorSameAsPositive", "1");
+    writer.writeAttribute("axisPosition", "none");
+    writer.writeStartElement(extNS, "cfvo");
+    writer.writeAttribute("type", "num");
+    writer.writeStartElement(xmNS, "f");
+    writer.writeCharacters("0");
+    writer.writeEndElement(); // f
+    writer.writeEndElement(); // cfvo
+
+    writer.writeStartElement(extNS, "cfvo");
+    writer.writeAttribute("type", "num");
+    writer.writeStartElement(xmNS, "f");
+    writer.writeCharacters("100");
+    writer.writeEndElement(); // f
+    writer.writeEndElement(); // cfvo
+    writer.writeEndElement(); // dataBar
+    writer.writeEndElement(); // cfrule
+
+    writer.writeStartElement(xmNS, "sqref");
+    writer.writeCharacters(sqref.join(QLatin1Char(' ')));
+    writer.writeEndElement(); // sqref
+
+    writer.writeEndElement(); // conditionalFormatting
+    writer.writeEndElement(); // conditionalFormattings
+
+    writer.writeEndElement(); //ext
+    writer.writeEndElement(); //extLst
     return true;
 }
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)