summaryrefslogtreecommitdiff
path: root/sheet.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2018-03-16 20:54:07 +0800
committerRi Xu <xuri.me@gmail.com>2018-03-16 20:54:07 +0800
commitd65b30055d247b3f51ffb6f3713a0e913790f0b3 (patch)
tree6e30fa3c012bfd9066851314e9665b3f4edfb792 /sheet.go
parent770026e956508e1ff0d1563617d7a3c8f212fb22 (diff)
- Update the function `NewSheet()` to handle when already exists a worksheet of the same name, relate pull request #196;
- go test and godoc has been updated
Diffstat (limited to 'sheet.go')
-rw-r--r--sheet.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/sheet.go b/sheet.go
index ae79acb..bc7cb75 100644
--- a/sheet.go
+++ b/sheet.go
@@ -13,9 +13,13 @@ import (
)
// NewSheet provides function to create a new sheet by given index, when
-// creating a new XLSX file, the default sheet will be create, when you create a
-// new file.
+// creating a new XLSX file, the default sheet will be create, when you create
+// a new file.
func (f *File) NewSheet(name string) int {
+ // Check if the worksheet already exists
+ if f.GetSheetIndex(name) != 0 {
+ return f.SheetCount
+ }
f.SheetCount++
// Update docProps/app.xml
f.setAppXML()