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 /comment.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 'comment.go')
-rw-r--r-- | comment.go | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -72,7 +72,7 @@ func (f *File) getSheetComments(sheetID int) string { // author length is 255 and the max text length is 32512. For example, add a // comment in Sheet1!$A$30: // -// xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize: ","text":"This is a comment."}`) +// err := xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize: ","text":"This is a comment."}`) // func (f *File) AddComment(sheet, cell, format string) error { formatSet, err := parseFormatCommentsSet(format) @@ -107,15 +107,21 @@ func (f *File) AddComment(sheet, cell, format string) error { colCount = ll } } - f.addDrawingVML(commentID, drawingVML, cell, strings.Count(formatSet.Text, "\n")+1, colCount) + err = f.addDrawingVML(commentID, drawingVML, cell, strings.Count(formatSet.Text, "\n")+1, colCount) + if err != nil { + return err + } f.addContentTypePart(commentID, "comments") return err } // addDrawingVML provides a function to create comment as // xl/drawings/vmlDrawing%d.vml by given commit ID and cell. -func (f *File) addDrawingVML(commentID int, drawingVML, cell string, lineCount, colCount int) { - col, row := MustCellNameToCoordinates(cell) +func (f *File) addDrawingVML(commentID int, drawingVML, cell string, lineCount, colCount int) error { + col, row, err := CellNameToCoordinates(cell) + if err != nil { + return err + } yAxis := col - 1 xAxis := row - 1 vml := f.VMLDrawing[drawingVML] @@ -206,6 +212,7 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string, lineCount, } vml.Shape = append(vml.Shape, shape) f.VMLDrawing[drawingVML] = vml + return err } // addComment provides a function to create chart as xl/comments%d.xml by |