Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetSheetCol feature #1247

Closed
stanleyyzhu opened this issue Jun 9, 2022 · 2 comments · Fixed by #1320
Closed

SetSheetCol feature #1247

stanleyyzhu opened this issue Jun 9, 2022 · 2 comments · Fixed by #1320
Labels
enhancement New feature or request

Comments

@stanleyyzhu
Copy link

How about adding a new method "SetSheetCol"

I do see "func (f *File) SetSheetRow(sheet, axis string, slice interface{}) error {}" in the latest release but I can't find the similar method for Col.

Shall we add a method for setting up sheet col values? It could be really similar as "SetSheetRow"

func (f *File) SetSheetCol(sheet, axis string, slice interface{}) error {
	col, row, err := CellNameToCoordinates(axis)
	if err != nil {
		return err
	}

	// Make sure 'slice' is a Ptr to Slice
	v := reflect.ValueOf(slice)
	if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Slice {
		return errors.New("pointer to slice expected")
	}
	v = v.Elem()

	for i := 0; i < v.Len(); i++ {
		cell, err := CoordinatesToCellName(col, row+i)
		// Error should never happens here. But keep checking to early detect regresions
		// if it will be introduced in future.
		if err != nil {
			return err
		}
		if err := f.SetCellValue(sheet, cell, v.Index(i).Interface()); err != nil {
			return err
		}
	}
	return err
}
@xuri
Copy link
Member

xuri commented Jun 15, 2022

Thanks for your issue. To add this feature, we need to create the common function to check cell reference and value reflection for SetSheetCol and SetSheetRow, which can be made code simple and clean.

@xuri xuri added the enhancement New feature or request label Jun 15, 2022
@xuri xuri linked a pull request Aug 24, 2022 that will close this issue
10 tasks
xuri pushed a commit that referenced this issue Aug 25, 2022
…olumn values (#1320)

Signed-off-by: cdenicola <cooper.denicola@instabase.com>
Co-authored-by: cdenicola <cooper.denicola@instabase.com>
rodoard pushed a commit to sheetrocks/excelize that referenced this issue Aug 26, 2022
…heet column values (qax-os#1320)

Signed-off-by: cdenicola <cooper.denicola@instabase.com>
Co-authored-by: cdenicola <cooper.denicola@instabase.com>
@stanleyyzhu
Copy link
Author

Thank you xuri

xuri pushed a commit to carbin-gun/excelize that referenced this issue Oct 9, 2022
…heet column values (qax-os#1320)

Signed-off-by: cdenicola <cooper.denicola@instabase.com>
Co-authored-by: cdenicola <cooper.denicola@instabase.com>
xuri pushed a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
…heet column values (qax-os#1320)

Signed-off-by: cdenicola <cooper.denicola@instabase.com>
Co-authored-by: cdenicola <cooper.denicola@instabase.com>
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…heet column values (qax-os#1320)

Signed-off-by: cdenicola <cooper.denicola@instabase.com>
Co-authored-by: cdenicola <cooper.denicola@instabase.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants