From 551fb8a9e4b03fe718a339e75aeacc8b5581378a Mon Sep 17 00:00:00 2001 From: xuri Date: Sat, 13 Aug 2022 11:21:59 +0800 Subject: This closes #1244 and closes #1314, improving the compatibility with Google Sheet - Format code with `gofmt` --- table.go | 83 +++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'table.go') diff --git a/table.go b/table.go index cf9c22a..dc5f441 100644 --- a/table.go +++ b/table.go @@ -32,18 +32,18 @@ func parseFormatTableSet(formatSet string) (*formatTable, error) { // name, coordinate area and format set. For example, create a table of A1:D5 // on Sheet1: // -// err := f.AddTable("Sheet1", "A1", "D5", "") +// err := f.AddTable("Sheet1", "A1", "D5", "") // // Create a table of F2:H6 on Sheet2 with format set: // -// err := f.AddTable("Sheet2", "F2", "H6", `{ -// "table_name": "table", -// "table_style": "TableStyleMedium2", -// "show_first_column": true, -// "show_last_column": true, -// "show_row_stripes": false, -// "show_column_stripes": true -// }`) +// err := f.AddTable("Sheet2", "F2", "H6", `{ +// "table_name": "table", +// "table_style": "TableStyleMedium2", +// "show_first_column": true, +// "show_last_column": true, +// "show_row_stripes": false, +// "show_column_stripes": true +// }`) // // Note that the table must be at least two lines including the header. The // header cells must contain strings and must be unique, and must set the @@ -54,10 +54,9 @@ func parseFormatTableSet(formatSet string) (*formatTable, error) { // // table_style: The built-in table style names // -// TableStyleLight1 - TableStyleLight21 -// TableStyleMedium1 - TableStyleMedium28 -// TableStyleDark1 - TableStyleDark11 -// +// TableStyleLight1 - TableStyleLight21 +// TableStyleMedium1 - TableStyleMedium28 +// TableStyleDark1 - TableStyleDark11 func (f *File) AddTable(sheet, hCell, vCell, format string) error { formatSet, err := parseFormatTableSet(format) if err != nil { @@ -216,11 +215,11 @@ func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) { // way of filtering a 2D range of data based on some simple criteria. For // example applying an autofilter to a cell range A1:D4 in the Sheet1: // -// err := f.AutoFilter("Sheet1", "A1", "D4", "") +// err := f.AutoFilter("Sheet1", "A1", "D4", "") // // Filter data in an autofilter: // -// err := f.AutoFilter("Sheet1", "A1", "D4", `{"column":"B","expression":"x != blanks"}`) +// err := f.AutoFilter("Sheet1", "A1", "D4", `{"column":"B","expression":"x != blanks"}`) // // column defines the filter columns in a autofilter range based on simple // criteria @@ -235,38 +234,38 @@ func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) { // expression defines the conditions, the following operators are available // for setting the filter criteria: // -// == -// != -// > -// < -// >= -// <= -// and -// or +// == +// != +// > +// < +// >= +// <= +// and +// or // // An expression can comprise a single statement or two statements separated // by the 'and' and 'or' operators. For example: // -// x < 2000 -// x > 2000 -// x == 2000 -// x > 2000 and x < 5000 -// x == 2000 or x == 5000 +// x < 2000 +// x > 2000 +// x == 2000 +// x > 2000 and x < 5000 +// x == 2000 or x == 5000 // // Filtering of blank or non-blank data can be achieved by using a value of // Blanks or NonBlanks in the expression: // -// x == Blanks -// x == NonBlanks +// x == Blanks +// x == NonBlanks // // Excel also allows some simple string matching operations: // -// x == b* // begins with b -// x != b* // doesn't begin with b -// x == *b // ends with b -// x != *b // doesn't end with b -// x == *b* // contains b -// x != *b* // doesn't contains b +// x == b* // begins with b +// x != b* // doesn't begin with b +// x == *b // ends with b +// x != *b // doesn't end with b +// x == *b* // contains b +// x != *b* // doesn't contains b // // You can also use '*' to match any character or number and '?' to match any // single character or number. No other regular expression quantifier is @@ -277,10 +276,9 @@ func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) { // simple string. The actual placeholder name is ignored internally so the // following are all equivalent: // -// x < 2000 -// col < 2000 -// Price < 2000 -// +// x < 2000 +// col < 2000 +// Price < 2000 func (f *File) AutoFilter(sheet, hCell, vCell, format string) error { hCol, hRow, err := CellNameToCoordinates(hCell) if err != nil { @@ -436,9 +434,8 @@ func (f *File) writeCustomFilter(filter *xlsxAutoFilter, operator int, val strin // // Examples: // -// ('x', '==', 2000) -> exp1 -// ('x', '>', 2000, 'and', 'x', '<', 5000) -> exp1 and exp2 -// +// ('x', '==', 2000) -> exp1 +// ('x', '>', 2000, 'and', 'x', '<', 5000) -> exp1 and exp2 func (f *File) parseFilterExpression(expression string, tokens []string) ([]int, []string, error) { var expressions []int var t []string -- cgit v1.2.1