-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Concurrent reading from cell is not supported? #861
Comments
Thanks for your issue, currently, this library doesn't support reading data concurrently. |
@xuri is it possible to be supported? is it be supported on the way? |
@xuri I want to fork a private repository for the concurrent reading feature. And if i can ignore writing scenario, is it easy to realize my goal? can you help me with any good prompt? |
Use |
@xuri many thanks |
@xuri Okay, my concurrent reading problem is solved by this issue. I wonder if it is easy to support concurrent writing. If use sync.Map instead of the unsafe map, then concurrent writing can be realized. I would like to contribute this project with a pull request in my spare time. And this is my temporary solution for concurrent reading. package excelize
import "sync"
const (
real_delete = false
)
type RWMapRelationships struct {
relationships map[string]*xlsxRelationships
rwl sync.RWMutex
}
func NewRWMapRelationships() *RWMapRelationships {
return &RWMapRelationships{
relationships: make(map[string]*xlsxRelationships),
}
}
func (rwmap *RWMapRelationships) GetSet(key string, extract func(string) *xlsxRelationships) *xlsxRelationships {
rwmap.rwl.RLock()
val := rwmap.relationships[key]
rwmap.rwl.RUnlock()
if val != nil {
return val
}
rwmap.rwl.Lock()
val = rwmap.relationships[key]
if val == nil {
if extract != nil {
val = extract(key)
rwmap.relationships[key] = val
}
}
rwmap.rwl.Unlock()
return val
}
func (rwmap *RWMapRelationships) Get(key string) *xlsxRelationships {
rwmap.rwl.RLock()
val := rwmap.relationships[key]
rwmap.rwl.RUnlock()
return val
}
func (rwmap *RWMapRelationships) Set(key string, val *xlsxRelationships) {
rwmap.rwl.Lock()
rwmap.relationships[key] = val
rwmap.rwl.Unlock()
}
func (rwmap *RWMapRelationships) Delete(key string) {
rwmap.rwl.Lock()
if !real_delete {
rwmap.relationships[key] = nil
} else {
delete(rwmap.relationships, key)
}
rwmap.rwl.Unlock()
}
func (rwmap *RWMapRelationships) Shadow() map[string]*xlsxRelationships {
rwmap.rwl.RLock()
s := make(map[string]*xlsxRelationships, len(rwmap.relationships))
for key, val := range rwmap.relationships {
s[key] = val
}
rwmap.rwl.RUnlock()
return s
}
type RWMapDrawings struct {
drawings map[string]*xlsxWsDr
rwl sync.RWMutex
}
func NewRWMapDrawings() *RWMapDrawings {
return &RWMapDrawings{
drawings: make(map[string]*xlsxWsDr),
}
}
func (rwmap *RWMapDrawings) GetSet(key string, extract func(string) *xlsxWsDr) *xlsxWsDr {
rwmap.rwl.RLock()
val := rwmap.drawings[key]
rwmap.rwl.RUnlock()
if val != nil {
return val
}
rwmap.rwl.Lock()
val = rwmap.drawings[key]
if val == nil {
if extract != nil {
val = extract(key)
rwmap.drawings[key] = val
}
}
rwmap.rwl.Unlock()
return val
}
func (rwmap *RWMapDrawings) Get(key string) *xlsxWsDr {
rwmap.rwl.RLock()
val := rwmap.drawings[key]
rwmap.rwl.RUnlock()
return val
}
func (rwmap *RWMapDrawings) Set(key string, val *xlsxWsDr) {
rwmap.rwl.Lock()
rwmap.drawings[key] = val
rwmap.rwl.Unlock()
}
func (rwmap *RWMapDrawings) Delete(key string) {
rwmap.rwl.Lock()
if !real_delete {
rwmap.drawings[key] = nil
} else {
delete(rwmap.drawings, key)
}
rwmap.rwl.Unlock()
}
func (rwmap *RWMapDrawings) Shadow() map[string]*xlsxWsDr {
rwmap.rwl.RLock()
s := make(map[string]*xlsxWsDr, len(rwmap.drawings))
for key, val := range rwmap.drawings {
s[key] = val
}
rwmap.rwl.RUnlock()
return s
} |
I have added concurrency get cell picture support, please try to upgrade the master branch code, and this feature will be released in the next version. |
…ve unused internal function `getSheetNameByID`
Description
Steps to reproduce the issue:
Test Excel
test_import_goods.xlsx
Test Code
Describe the results you received:
Describe the results you expected:
Output of
go version
:Excelize version or commit ID:
Output of Error message:
Environment details (OS, Microsoft Excel™ version, physical, etc.):
The text was updated successfully, but these errors were encountered: