summaryrefslogtreecommitdiff
path: root/excelize.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 /excelize.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 'excelize.go')
-rw-r--r--excelize.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/excelize.go b/excelize.go
index 7a50460..857f3ac 100644
--- a/excelize.go
+++ b/excelize.go
@@ -98,11 +98,16 @@ func OpenReader(r io.Reader) (*File, error) {
// setDefaultTimeStyle provides a function to set default numbers format for
// time.Time type cell value by given worksheet name, cell coordinates and
// number format code.
-func (f *File) setDefaultTimeStyle(sheet, axis string, format int) {
- if f.GetCellStyle(sheet, axis) == 0 {
+func (f *File) setDefaultTimeStyle(sheet, axis string, format int) error {
+ s, err := f.GetCellStyle(sheet, axis)
+ if err != nil {
+ return err
+ }
+ if s == 0 {
style, _ := f.NewStyle(`{"number_format": ` + strconv.Itoa(format) + `}`)
f.SetCellStyle(sheet, axis, axis, style)
}
+ return err
}
// workSheetReader provides a function to get the pointer to the structure
@@ -218,7 +223,8 @@ func (f *File) GetMergeCells(sheet string) []MergeCell {
for i := range xlsx.MergeCells.Cells {
ref := xlsx.MergeCells.Cells[i].Ref
axis := strings.Split(ref, ":")[0]
- mergeCells = append(mergeCells, []string{ref, f.GetCellValue(sheet, axis)})
+ val, _ := f.GetCellValue(sheet, axis)
+ mergeCells = append(mergeCells, []string{ref, val})
}
}