Skip to content

Drop-down list items are not XML escaped #971

@Arnie97

Description

@Arnie97

Description

If any of the XML special characters <, >, &, " were used in SetDropList() choices, the produced file will be reported as corrupted.

Steps to reproduce the issue:

package main

import (
	"github.com/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
	var jobs = []string{"R&D", "PM", "UX", "HR"}
	newWorkbookWithDropList(jobs)
}

func newWorkbookWithDropList(choices []string) {
	f := excelize.NewFile()
	dv := excelize.NewDataValidation(false)
	dv.Sqref = "A:A"
	if err := dv.SetDropList(choices); err != nil {
		panic(err)
	}
	f.AddDataValidation(f.GetSheetName(0), dv)
	f.SaveAs("TestDropList.xlsx")
}

Describe the results you received:

image

image

Describe the results you expected:

image

Output of go version:

go version go1.17rc1 linux/amd64

Excelize version or commit ID:

Environment details (OS, Microsoft Excel™ version, etc.):

The following official implementation were tested, and all of them could reproduce this issue:

  • Microsoft Office 365 for Mac, 16.49 (21050901)
  • Microsoft Office 365 for Windows, 2102 (Build 13801.20808)
  • Microsoft Office 2019 Professional Plus for Windows, 2105 (Build 14026.20302)
  • Microsoft Office 2013 Professional Plus for Windows, 15.0.4919.1002

The following third-party implementations were also tested, but none of them was affected by the issue:

  • Kingsoft WPS
  • Apple Numbers
  • Google Sheets
  • LibreOffice

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmedThis issue can be reproduced

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions