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

Can't modify cell content of xlsx file exported from server #1263

Closed
Lin07ux opened this issue Jun 30, 2022 · 2 comments
Closed

Can't modify cell content of xlsx file exported from server #1263

Lin07ux opened this issue Jun 30, 2022 · 2 comments
Labels
confirmed This issue can be reproduced

Comments

@Lin07ux
Copy link

Lin07ux commented Jun 30, 2022

Description

I have an excel file exported from server, i can use excelize@v2 to modify its style and modify the content of empty cells, but I can't modify the content of cells that already have content.

Steps to reproduce the issue:

  1. export excel file from server (you can open the file, but don't modify it use any software like WPS or MS Office). orders-20220628222630-20220629173554.xlsx
  2. use excelize to process the file, the above situation will occur .
  3. use WPS open and modify any cell in the file and save it.
  4. then use excelize to process the file, and everything is ok.

Describe the results you received:

I can't change the content of A1 cell.

Describe the results you expected:

change the content of A1 cell.

Output of go version:

go version go1.17.2 darwin/amd64

Excelize version or commit ID:

github.com/xuri/excelize/v2 v2.6.0

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

Mac OS, WPS 4.2.2

Example Code

package main

import (
	"github.com/xuri/excelize/v2"
	"log"
)

func main() {
	excel, err := excelize.OpenFile("~/Downloads/orders-20220628222630-20220629173554.xlsx")
	if err != nil {
		log.Fatalln(err)
	}
	defer func() {
		if err := excel.Save(); err != nil {
			log.Fatalln(err)
		}
		if err := excel.Close(); err != nil {
			log.Fatalln(err)
		}
	}()

	sheet := excel.GetSheetName(excel.GetActiveSheetIndex())

	// **not work**
	if err = excel.SetCellStr(sheet, "A1", "A1"); err != nil {
		log.Fatalln(err)
	}

	// ok
	if err = excel.SetCellStr(sheet, "B2", "B2"); err != nil {
		log.Fatalln(err)
	}

	style, err := excel.NewStyle(&excelize.Style{
		Border: []excelize.Border{
			{Type: "left", Color: "0000FF", Style: 3},
			{Type: "top", Color: "00FF00", Style: 4},
			{Type: "bottom", Color: "FFFF00", Style: 5},
			{Type: "right", Color: "FF0000", Style: 6},
			{Type: "diagonalDown", Color: "A020F0", Style: 7},
			{Type: "diagonalUp", Color: "A020F0", Style: 8},
		},
	})
	if err != nil {
		log.Fatalln(err)
	}

	// ok
	if err = excel.SetCellStyle(sheet, "D1", "D1", style); err != nil {
		log.Fatalln(err)
	}
}
@xuri xuri added confirmed This issue can be reproduced in progress Working in progress labels Jun 30, 2022
@xuri
Copy link
Member

xuri commented Jun 30, 2022

Thanks for your feedback. This issue has been fixed, please upgrade to the master branch code, and this patch will be released in the next version.

@xuri xuri closed this as completed Jun 30, 2022
@xuri xuri removed the in progress Working in progress label Jun 30, 2022
@Lin07ux
Copy link
Author

Lin07ux commented Jul 1, 2022

Thank you very much for your response and handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants