Giter Club home page Giter Club logo

Comments (2)

rednexela1941 avatar rednexela1941 commented on July 19, 2024

ran into a similar thing using InsertRows:

invalid column name "K31 E"

from excelize.

rednexela1941 avatar rednexela1941 commented on July 19, 2024

Some investigations:

Seems that the sheet I was reading and editing was using the same data validation twice.

inside of adjust.go

func (f *File) adjustDataValidations(ws *xlsxWorksheet, sheet string, dir adjustDirection, num, offset, sheetID int) error {
	for _, sheetN := range f.GetSheetList() {
		worksheet, err := f.workSheetReader(sheetN)
		if err != nil {
			if err.Error() == newNotWorksheetError(sheetN).Error() {
				continue
			}
			return err
		}
		if worksheet.DataValidations == nil {
			return nil
		}
		for i := 0; i < len(worksheet.DataValidations.DataValidation); i++ {
			dv := worksheet.DataValidations.DataValidation[i]
			if dv == nil {
				continue
			}
			if sheet == sheetN {
				fmt.Println("dv.Sqref", dv.Sqref) /// <<----------------HERE
				ref, del, err := f.adjustCellRef(dv.Sqref, dir, num, offset)

it was feeding two ranges:

dv.Sqref K9:K31 E8:E30

which in turn blew up the insides of lib.go:rangeRefToCoordinates

func rangeRefToCoordinates(ref string) ([]int, error) {
	rng := strings.Split(strings.ReplaceAll(ref, "$", ""), ":")
	if len(rng) < 2 {
		return nil, ErrParameterInvalid
	}
	fmt.Println(ref, "ref", rng[0], rng[1]) // HERE
	return cellRefsToCoordinates(rng[0], rng[1])
}

output:

K9:K31 E8:E30 ref K9 K31 E8

Temporary fix for me was to remove the problematic datavalidations before editing the sheet:

	if err := f.DeleteDataValidation(sheetName, "K9:K31", "E8:E30"); err != nil {
		return err
	}

from excelize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.