diff options
author | xuri <xuri.me@gmail.com> | 2019-03-23 20:08:06 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-03-23 20:08:06 +0800 |
commit | 40ff5dc1a7d7aa42f5db9cf9dfe858cc3820b44e (patch) | |
tree | 9683b0a18a08f6603065506589a3c86dba5b8bb1 /lib.go | |
parent | 2874d75555102b8266477cdda2966ff37dde6b12 (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 'lib.go')
-rw-r--r-- | lib.go | 53 |
1 files changed, 6 insertions, 47 deletions
@@ -135,22 +135,6 @@ func ColumnNameToNumber(name string) (int, error) { return col, nil } -// MustColumnNameToNumber provides a function to convert Excel sheet column -// name to int. Column name case insencitive. -// Function returns error if column name incorrect. -// -// Example: -// -// excelize.MustColumnNameToNumber("AK") // returns 37 -// -func MustColumnNameToNumber(name string) int { - n, err := ColumnNameToNumber(name) - if err != nil { - panic(err) - } - return n -} - // ColumnNumberToName provides a function to convert integer // to Excel sheet column title. // @@ -174,8 +158,9 @@ func ColumnNumberToName(num int) (string, error) { // to [X, Y] coordinates or retrusn an error. // // Example: -// CellCoordinates("A1") // returns 1, 1, nil -// CellCoordinates("Z3") // returns 26, 3, nil +// +// CellCoordinates("A1") // returns 1, 1, nil +// CellCoordinates("Z3") // returns 26, 3, nil // func CellNameToCoordinates(cell string) (int, int, error) { const msg = "cannot convert cell %q to coordinates: %v" @@ -193,25 +178,12 @@ func CellNameToCoordinates(cell string) (int, int, error) { return col, row, nil } -// MustCellNameToCoordinates converts alpha-numeric cell name -// to [X, Y] coordinates or panics. +// CoordinatesToCellName converts [X, Y] coordinates to alpha-numeric cell +// name or returns an error. // // Example: -// MustCellNameToCoordinates("A1") // returns 1, 1 -// MustCellNameToCoordinates("Z3") // returns 26, 3 // -func MustCellNameToCoordinates(cell string) (int, int) { - c, r, err := CellNameToCoordinates(cell) - if err != nil { - panic(err) - } - return c, r -} - -// CoordinatesToCellName converts [X, Y] coordinates to alpha-numeric cell name or returns an error. -// -// Example: -// CoordinatesToCellName(1, 1) // returns "A1", nil +// CoordinatesToCellName(1, 1) // returns "A1", nil // func CoordinatesToCellName(col, row int) (string, error) { if col < 1 || row < 1 { @@ -224,19 +196,6 @@ func CoordinatesToCellName(col, row int) (string, error) { return fmt.Sprintf("%s%d", colname, row), nil } -// MustCoordinatesToCellName converts [X, Y] coordinates to alpha-numeric cell name or panics. -// -// Example: -// MustCoordinatesToCellName(1, 1) // returns "A1" -// -func MustCoordinatesToCellName(col, row int) string { - n, err := CoordinatesToCellName(col, row) - if err != nil { - panic(err) - } - return n -} - // boolPtr returns a pointer to a bool with the given value. func boolPtr(b bool) *bool { return &b } |