- Fix formula percentages calculated incorrectly - Make UpdateLinkedValue skip macro sheet - Fix conditional format bottom N not working
This commit is contained in:
parent
32b23ef42d
commit
684603befa
14
calc.go
14
calc.go
|
@ -975,6 +975,11 @@ func isOperatorPrefixToken(token efp.Token) bool {
|
||||||
return (token.TValue == "-" && token.TType == efp.TokenTypeOperatorPrefix) || (ok && token.TType == efp.TokenTypeOperatorInfix)
|
return (token.TValue == "-" && token.TType == efp.TokenTypeOperatorPrefix) || (ok && token.TType == efp.TokenTypeOperatorInfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isOperand determine if the token is parse operand perand.
|
||||||
|
func isOperand(token efp.Token) bool {
|
||||||
|
return token.TType == efp.TokenTypeOperand && (token.TSubType == efp.TokenSubTypeNumber || token.TSubType == efp.TokenSubTypeText)
|
||||||
|
}
|
||||||
|
|
||||||
// getDefinedNameRefTo convert defined name to reference range.
|
// getDefinedNameRefTo convert defined name to reference range.
|
||||||
func (f *File) getDefinedNameRefTo(definedNameName string, currentSheet string) (refTo string) {
|
func (f *File) getDefinedNameRefTo(definedNameName string, currentSheet string) (refTo string) {
|
||||||
var workbookRefTo, worksheetRefTo string
|
var workbookRefTo, worksheetRefTo string
|
||||||
|
@ -1034,8 +1039,15 @@ func (f *File) parseToken(sheet string, token efp.Token, opdStack, optStack *Sta
|
||||||
}
|
}
|
||||||
optStack.Pop()
|
optStack.Pop()
|
||||||
}
|
}
|
||||||
|
if token.TType == efp.TokenTypeOperatorPostfix && !opdStack.Empty() {
|
||||||
|
topOpd := opdStack.Pop().(efp.Token)
|
||||||
|
opd, err := strconv.ParseFloat(topOpd.TValue, 64)
|
||||||
|
topOpd.TValue = strconv.FormatFloat(opd/100, 'f', -1, 64)
|
||||||
|
opdStack.Push(topOpd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
// opd
|
// opd
|
||||||
if token.TType == efp.TokenTypeOperand && (token.TSubType == efp.TokenSubTypeNumber || token.TSubType == efp.TokenSubTypeText) {
|
if isOperand(token) {
|
||||||
opdStack.Push(token)
|
opdStack.Push(token)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -46,6 +46,8 @@ func TestCalcCellValue(t *testing.T) {
|
||||||
"=2>=1": "TRUE",
|
"=2>=1": "TRUE",
|
||||||
"=2>=3": "FALSE",
|
"=2>=3": "FALSE",
|
||||||
"=1&2": "12",
|
"=1&2": "12",
|
||||||
|
"=15%": "0.15",
|
||||||
|
"=1+20%": "1.2",
|
||||||
`="A"="A"`: "TRUE",
|
`="A"="A"`: "TRUE",
|
||||||
`="A"<>"A"`: "FALSE",
|
`="A"<>"A"`: "FALSE",
|
||||||
// Engineering Functions
|
// Engineering Functions
|
||||||
|
|
|
@ -230,7 +230,7 @@ func TestAddChartSheet(t *testing.T) {
|
||||||
f.SetActiveSheet(sheetIdx)
|
f.SetActiveSheet(sheetIdx)
|
||||||
|
|
||||||
// Test cell value on chartsheet
|
// Test cell value on chartsheet
|
||||||
assert.EqualError(t, f.SetCellValue("Chart1", "A1", true), "sheet Chart1 is chart sheet")
|
assert.EqualError(t, f.SetCellValue("Chart1", "A1", true), "sheet Chart1 is not a worksheet")
|
||||||
// Test add chartsheet on already existing name sheet
|
// Test add chartsheet on already existing name sheet
|
||||||
assert.EqualError(t, f.AddChartSheet("Sheet1", `{"type":"col3DClustered","series":[{"name":"Sheet1!$A$2","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$2:$D$2"},{"name":"Sheet1!$A$3","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$3:$D$3"},{"name":"Sheet1!$A$4","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$4:$D$4"}],"title":{"name":"Fruit 3D Clustered Column Chart"}}`), ErrExistsWorksheet.Error())
|
assert.EqualError(t, f.AddChartSheet("Sheet1", `{"type":"col3DClustered","series":[{"name":"Sheet1!$A$2","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$2:$D$2"},{"name":"Sheet1!$A$3","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$3:$D$3"},{"name":"Sheet1!$A$4","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$4:$D$4"}],"title":{"name":"Fruit 3D Clustered Column Chart"}}`), ErrExistsWorksheet.Error())
|
||||||
// Test with unsupported chart type
|
// Test with unsupported chart type
|
||||||
|
|
|
@ -204,8 +204,8 @@ func (f *File) workSheetReader(sheet string) (ws *xlsxWorksheet, err error) {
|
||||||
ws = worksheet.(*xlsxWorksheet)
|
ws = worksheet.(*xlsxWorksheet)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(name, "xl/chartsheets") {
|
if strings.HasPrefix(name, "xl/chartsheets") || strings.HasPrefix(name, "xl/macrosheet") {
|
||||||
err = fmt.Errorf("sheet %s is chart sheet", sheet)
|
err = fmt.Errorf("sheet %s is not a worksheet", sheet)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ws = new(xlsxWorksheet)
|
ws = new(xlsxWorksheet)
|
||||||
|
@ -367,7 +367,7 @@ func (f *File) UpdateLinkedValue() error {
|
||||||
for _, name := range f.GetSheetList() {
|
for _, name := range f.GetSheetList() {
|
||||||
ws, err := f.workSheetReader(name)
|
ws, err := f.workSheetReader(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == fmt.Sprintf("sheet %s is chart sheet", trimSheetName(name)) {
|
if err.Error() == fmt.Sprintf("sheet %s is not a worksheet", trimSheetName(name)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -3011,6 +3011,7 @@ func drawCondFmtCellIs(p int, ct string, format *formatConditional) *xlsxCfRule
|
||||||
func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
|
func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
|
||||||
c := &xlsxCfRule{
|
c := &xlsxCfRule{
|
||||||
Priority: p + 1,
|
Priority: p + 1,
|
||||||
|
Bottom: format.Type == "bottom",
|
||||||
Type: validType[format.Type],
|
Type: validType[format.Type],
|
||||||
Rank: 10,
|
Rank: 10,
|
||||||
DxfID: &format.Format,
|
DxfID: &format.Format,
|
||||||
|
|
Loading…
Reference in New Issue