#2178·excelize

Generalize bufferWriter for non-local files usage

Author: eliyaoo32Created Jul 19, 2025Updated Feb 8, 2026

Description

Hi, currently the bufferWriter is dedicated to be written to a file in the hard-disk / local filesystem. There are cases (Such the one I face) where a little bit of hard-disk space is available (no more than few MBs), but we do have access to a distributed file system / object storage (Such as: S3 file, GCS file, etc...).

I suggest to make the bufferWrite as an interface:

go
type bufferedWriter interface {
	Write(p []byte) (n int, err error)
	WriteString(s string) (n int, err error)
	Reader() (io.Reader, error)
	Sync() (err error)
	Flush() error
	Close() error
}

To have backward-compability , it will use the current implementation of bufferedWriter as a default struct. But in the function: NewStreamWriter as an option it can get BufferedWriter as a parameter and use it. i.e.

NewStreamWriter(sheetName, WithBufferedWriter(anotherImplementation{}))

I'm ready to contribute this change since I need it, but happy to hear what the owners of this project think about it.

Additional context

No response

Validations

  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.