xuri vor 7 Jahren
Ursprung
Commit
79dfe1c307
8 geänderte Dateien mit 18 neuen und 7 gelöschten Zeilen
  1. 1 1
      README.md
  2. 1 1
      README_zh.md
  3. 2 0
      chart.go
  4. 2 2
      comment.go
  5. 9 0
      lib.go
  6. 1 1
      picture.go
  7. 1 1
      styles.go
  8. 1 1
      table.go

+ 1 - 1
README.md

@@ -11,7 +11,7 @@
 
 ## Introduction
 
-Excelize is a library written in pure Go and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Microsoft Excel™ 2007 and later. Support save file without losing original charts of XLSX. This library needs Go version 1.8 or later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) and [Chinese translation](https://xuri.me/excelize/zh_cn).
+Excelize is a library written in pure Go and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Microsoft Excel™ 2007 and later. Support save file without losing original charts of XLSX. This library needs Go version 1.8 or later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) and [docs reference](https://xuri.me/excelize/).
 
 ## Basic Usage
 

+ 1 - 1
README_zh.md

@@ -11,7 +11,7 @@
 
 ## 简介
 
-Excelize 是 Go 语言编写的用于操作 Office Excel 文档类库,基于 ECMA-376 Office OpenXML 标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的 XLSX 文档。相比较其他的开源类库,Excelize 支持写入原本带有图片(表)、透视表和切片器等复杂样式的文档,还支持向 Excel 文档中插入图片与图表,并且在保存后不会丢失文档原有样式,可以应用于各类报表系统中。使用本类库要求使用的 Go 语言为 1.8 或更高版本,完整的 API 使用文档请访问 [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) 或查看 [中文翻译](https://xuri.me/excelize/zh_cn)。
+Excelize 是 Go 语言编写的用于操作 Office Excel 文档类库,基于 ECMA-376 Office OpenXML 标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的 XLSX 文档。相比较其他的开源类库,Excelize 支持写入原本带有图片(表)、透视表和切片器等复杂样式的文档,还支持向 Excel 文档中插入图片与图表,并且在保存后不会丢失文档原有样式,可以应用于各类报表系统中。使用本类库要求使用的 Go 语言为 1.8 或更高版本,完整的 API 使用文档请访问 [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) 或查看 [参考文档](https://xuri.me/excelize/)。
 
 ## 快速上手
 

+ 2 - 0
chart.go

@@ -352,7 +352,9 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) {
 //    minimum
 //
 // reverse_order: Specifies that the categories or values on reverse order (orientation of the chart). The reverse_order property is optional. The default value is false.
+//
 // maximum: Specifies that the fixed maximum, 0 is auto. The maximum property is optional. The default value is auto.
+//
 // minimum: Specifies that the fixed minimum, 0 is auto. The minimum property is optional. The default value is auto.
 //
 // Set chart size by dimension property. The dimension property is optional. The default width is 480, and height is 290.

+ 2 - 2
comment.go

@@ -15,11 +15,11 @@ func parseFormatCommentsSet(formatSet string) (*formatComment, error) {
 		Author: "Author:",
 		Text:   " ",
 	}
-	err := json.Unmarshal([]byte(formatSet), &format)
+	err := json.Unmarshal(parseFormatSet(formatSet), &format)
 	return &format, err
 }
 
-// GetComments retrievs all comments and returns a map
+// GetComments retrieves all comments and returns a map
 // of worksheet name to the worksheet comments.
 func (f *File) GetComments() (comments map[string]*xlsxComments) {
 	comments = map[string]*xlsxComments{}

+ 9 - 0
lib.go

@@ -164,3 +164,12 @@ func getCellColRow(cell string) (col, row string) {
 
 	return cell, ""
 }
+
+// parseFormatSet provides a method to convert format string to []byte and
+// handle empty string.
+func parseFormatSet(formatSet string) []byte {
+	if formatSet != "" {
+		return []byte(formatSet)
+	}
+	return []byte("{}")
+}

+ 1 - 1
picture.go

@@ -26,7 +26,7 @@ func parseFormatPictureSet(formatSet string) (*formatPicture, error) {
 		XScale:           1.0,
 		YScale:           1.0,
 	}
-	err := json.Unmarshal([]byte(formatSet), &format)
+	err := json.Unmarshal(parseFormatSet(formatSet), &format)
 	return &format, err
 }
 

+ 1 - 1
styles.go

@@ -2407,7 +2407,7 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
 //
 // The criteria parameter is used to set the criteria by which the cell data
 // will be evaluated. It has no default value. The most common criteria as
-// applied to {'type': 'cell'} are:
+// applied to {"type":"cell"} are:
 //
 //    between                  |
 //    not between              |

+ 1 - 1
table.go

@@ -16,7 +16,7 @@ func parseFormatTableSet(formatSet string) (*formatTable, error) {
 		TableStyle:     "",
 		ShowRowStripes: true,
 	}
-	err := json.Unmarshal([]byte(formatSet), &format)
+	err := json.Unmarshal(parseFormatSet(formatSet), &format)
 	return &format, err
 }