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

Close error: The process cannot access the file because it is being used by another process #2020

Open
lonevle opened this issue Nov 6, 2024 · 1 comment

Comments

@lonevle
Copy link

lonevle commented Nov 6, 2024

Description

Steps to reproduce the issue:

package main

import (
	"fmt"
	"os"

	"github.com/xuri/excelize/v2"
)

func test(filepath string) error {
	var data = 0
	f, err := excelize.OpenFile(filepath)
	if err != nil {
		return err
	}
	defer func() {
		if err := f.Close(); err != nil {
			fmt.Println("File close failed", err)
		}
	}()
	sheetName := f.GetSheetName(0)
	rows, err := f.Rows(sheetName)
	if err != nil {
		return err
	}
	for rows.Next() {
		data += 1
	}
	return nil
}

func main() {
	test(os.Args[1])
}

excel file: lonevle/bug

Describe the results you received:
image

Output of go version:

File close failed remove C:\Users\iyous\AppData\Local\Temp\excelize-3729237196: The process cannot access the file because it is being used by another process.

Excelize version or commit ID:

v2.9.0

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

@lonevle
Copy link
Author

lonevle commented Nov 6, 2024

Please use this file to test
text.xlsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant