MCPcopy
hub / github.com/qax-os/excelize / transformArrayFormula

Function transformArrayFormula

adjust.go:545–570  ·  view source on GitHub ↗

transformArrayFormula transforms an array formula to the normal formula by giving a formula tokens list and formula operand tokens list.

(tokens []efp.Token, afs []arrayFormulaOperandToken)

Source from the content-addressed store, hash-verified

543// transformArrayFormula transforms an array formula to the normal formula by
544// giving a formula tokens list and formula operand tokens list.
545func transformArrayFormula(tokens []efp.Token, afs []arrayFormulaOperandToken) string {
546 var val string
547 for i, token := range tokens {
548 var skip bool
549 for _, af := range afs {
550 if af.operandTokenIndex == i {
551 val += af.sheetName + af.targetCellRef
552 skip = true
553 break
554 }
555 }
556 if skip {
557 continue
558 }
559 if paren := transformParenthesesToken(token); paren != "" {
560 val += transformParenthesesToken(token)
561 continue
562 }
563 if token.TType == efp.TokenTypeOperand && token.TSubType == efp.TokenSubTypeText {
564 val += string(efp.QuoteDouble) + strings.ReplaceAll(token.TValue, "\"", "\"\"") + string(efp.QuoteDouble)
565 continue
566 }
567 val += token.TValue
568 }
569 return val
570}
571
572// getArrayFormulaTokens returns parsed formula token and operand related token
573// list for in array formula.

Callers 1

setArrayFormulaMethod · 0.85

Calls 1

Tested by

no test coverage detected