diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BIFF12/FRTParsedFormula.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BIFF12/FRTParsedFormula.cpp index a37efd97a3..c71657be8e 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BIFF12/FRTParsedFormula.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/BIFF12/FRTParsedFormula.cpp @@ -81,6 +81,7 @@ void FRTParsedFormula::save(XLS::CFRecord& record) record.RollRdPtrBack(cce + 8); record << cce; record.skipNunBytes(cce + 4); + this->cce = cce; } diff --git a/OOXML/XlsbFormat/Biff12_records/BeginCFRule14.cpp b/OOXML/XlsbFormat/Biff12_records/BeginCFRule14.cpp index e43a155155..b8e6f6d146 100644 --- a/OOXML/XlsbFormat/Biff12_records/BeginCFRule14.cpp +++ b/OOXML/XlsbFormat/Biff12_records/BeginCFRule14.cpp @@ -104,6 +104,12 @@ namespace XLSB record << flags; + if(cbFmla1 > 0 && !FRTheader.rgFormulas.array.empty()) + cbFmla1 = FRTheader.rgFormulas.array.at(0).formula.cce; + else if(cbFmla3 > 0 && !FRTheader.rgFormulas.array.empty()) + cbFmla3 = FRTheader.rgFormulas.array.at(0).formula.cce; + if(cbFmla2 > 0 && FRTheader.rgFormulas.array.size() > 1) + cbFmla2 = FRTheader.rgFormulas.array.at(1).formula.cce; record << cbFmla1 << cbFmla2 << cbFmla3; record.reserveNunBytes(4); diff --git a/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp b/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp index a4f78ba415..6f96a8866d 100644 --- a/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp +++ b/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp @@ -278,6 +278,12 @@ XLS::BaseObjectPtr CConditionalFormatValueObject::toBin(bool isIcon) if(static_cast<_UINT32>(ptr1->iType) == XLSB::CFVOtype::CFVOFMLA && m_oVal.IsInit()) { ptr1->formula = m_oVal.get(); + auto lastValType = GETBITS(ptr1->formula.rgce.sequence.rbegin()->get()->ptg_id.get(),5,6); + if(lastValType == 1 || lastValType == 3) + { + SETBITS(ptr1->formula.rgce.sequence.rbegin()->get()->ptg_id.get(),5,6,2); + } + ptr1->cbFmla = 1; } else @@ -2406,7 +2412,41 @@ XLS::BaseObjectPtr CConditionalFormattingRule::WriteAttributes14(const XLS::Cel } if(!ptr->FRTheader.rgFormulas.array.empty()) ptr->FRTheader.fFormula = true; + + if(m_oType == SimpleTypes::Spreadsheet::ECfType::colorScale || m_oType == SimpleTypes::Spreadsheet::ECfType::dataBar + || m_oType == SimpleTypes::Spreadsheet::ECfType::iconSet) + ptr->cbFmla3 = 1; + else + ptr->cbFmla1 = 1; + if(m_arrFormula.size() > 1) + ptr->cbFmla2 = 1; } + + if(!m_arrFormula.empty() && !m_arrFormula.front()->m_sText.empty()) + { + ptr->cbFmla1 = 1; + } + else + { + ptr->cbFmla1 = 0; + } + if(!m_arrFormula.empty() && !m_arrFormula.front()->m_sText.empty()) + { + ptr->cbFmla2 = 1; + } + else + { + ptr->cbFmla2 = 0; + } + if(!m_arrFormula.empty() && !m_arrFormula.front()->m_sText.empty()) + { + ptr->cbFmla3 = 1; + } + else + { + ptr->cbFmla3 = 0; + } + ptr->iType = XLSB::CFType::CF_TYPE_EXPRIS; ptr->iParam =0; ptr->iTemplate = XLSB::CFTemp::CF_TEMPLATE_EXPR;