summaryrefslogtreecommitdiff
path: root/sheet.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2019-03-23 20:08:06 +0800
committerxuri <xuri.me@gmail.com>2019-03-23 20:08:06 +0800
commit40ff5dc1a7d7aa42f5db9cf9dfe858cc3820b44e (patch)
tree9683b0a18a08f6603065506589a3c86dba5b8bb1 /sheet.go
parent2874d75555102b8266477cdda2966ff37dde6b12 (diff)
refactor: handler error instead of panic,
Exported functions: SetCellStyle InsertCol RemoveCol RemoveRow InsertRow DuplicateRow DuplicateRowTo SetRowHeight GetRowHeight GetCellValue GetCellFormula GetCellHyperLink SetCellHyperLink SetCellInt SetCellBool SetCellFloat SetCellStr SetCellDefault GetCellStyle SetCellValue MergeCell SetSheetRow SetRowVisible GetRowVisible SetRowOutlineLevel GetRowOutlineLevel GetRows Columns SearchSheet AddTable GetPicture AutoFilter GetColVisible SetColVisible GetColOutlineLevel SetColOutlineLevel SetColWidth GetColWidth inner functions: adjustHelper adjustMergeCells adjustAutoFilter prepareCell setDefaultTimeStyle timeToExcelTime addDrawingChart addDrawingVML addDrawingPicture getTotalRowsCols checkRow addDrawingShape addTable
Diffstat (limited to 'sheet.go')
-rw-r--r--sheet.go31
1 files changed, 19 insertions, 12 deletions
diff --git a/sheet.go b/sheet.go
index ce1f241..ec4df77 100644
--- a/sheet.go
+++ b/sheet.go
@@ -275,11 +275,11 @@ func (f *File) GetActiveSheetIndex() int {
return 0
}
-// SetSheetName provides a function to set the worksheet name be given old and new
-// worksheet name. Maximum 31 characters are allowed in sheet title and this
-// function only changes the name of the sheet and will not update the sheet
-// name in the formula or reference associated with the cell. So there may be
-// problem formula error or reference missing.
+// SetSheetName provides a function to set the worksheet name be given old and
+// new worksheet name. Maximum 31 characters are allowed in sheet title and
+// this function only changes the name of the sheet and will not update the
+// sheet name in the formula or reference associated with the cell. So there
+// may be problem formula error or reference missing.
func (f *File) SetSheetName(oldName, newName string) {
oldName = trimSheetName(oldName)
newName = trimSheetName(newName)
@@ -665,14 +665,14 @@ func (f *File) GetSheetVisible(name string) bool {
//
// An example of search the coordinates of the value of "100" on Sheet1:
//
-// xlsx.SearchSheet("Sheet1", "100")
+// result, err := xlsx.SearchSheet("Sheet1", "100")
//
// An example of search the coordinates where the numerical value in the range
// of "0-9" of Sheet1 is described:
//
-// xlsx.SearchSheet("Sheet1", "[0-9]", true)
+// result, err := xlsx.SearchSheet("Sheet1", "[0-9]", true)
//
-func (f *File) SearchSheet(sheet, value string, reg ...bool) []string {
+func (f *File) SearchSheet(sheet, value string, reg ...bool) ([]string, error) {
var regSearch bool
for _, r := range reg {
regSearch = r
@@ -683,7 +683,7 @@ func (f *File) SearchSheet(sheet, value string, reg ...bool) []string {
)
name, ok := f.sheetMap[trimSheetName(sheet)]
if !ok {
- return result
+ return result, nil
}
if xlsx != nil {
output, _ := xml.Marshal(f.Sheet[name])
@@ -718,14 +718,21 @@ func (f *File) SearchSheet(sheet, value string, reg ...bool) []string {
}
}
- cellCol, _ := MustCellNameToCoordinates(colCell.R)
- result = append(result, MustCoordinatesToCellName(cellCol, r.R))
+ cellCol, _, err := CellNameToCoordinates(colCell.R)
+ if err != nil {
+ return result, err
+ }
+ cellName, err := CoordinatesToCellName(cellCol, r.R)
+ if err != nil {
+ return result, err
+ }
+ result = append(result, cellName)
}
}
default:
}
}
- return result
+ return result, nil
}
// ProtectSheet provides a function to prevent other users from accidentally