|
1 | | -// Copyright 2016 - 2022 The excelize Authors. All rights reserved. Use of |
| 1 | +// Copyright 2016 - 2023 The excelize Authors. All rights reserved. Use of |
2 | 2 | // this source code is governed by a BSD-style license that can be found in |
3 | 3 | // the LICENSE file. |
4 | 4 | // |
|
7 | 7 | // writing spreadsheet documents generated by Microsoft Excel™ 2007 and later. |
8 | 8 | // Supports complex components by high compatibility, and provided streaming |
9 | 9 | // API for generating or reading data from a worksheet with huge amounts of |
10 | | -// data. This library needs Go version 1.15 or later. |
| 10 | +// data. This library needs Go version 1.16 or later. |
11 | 11 |
|
12 | 12 | package excelize |
13 | 13 |
|
@@ -679,6 +679,11 @@ type FormulaOpts struct { |
679 | 679 | // |
680 | 680 | // func main() { |
681 | 681 | // f := excelize.NewFile() |
| 682 | +// defer func() { |
| 683 | +// if err := f.Close(); err != nil { |
| 684 | +// fmt.Println(err) |
| 685 | +// } |
| 686 | +// }() |
682 | 687 | // for idx, row := range [][]interface{}{{"A", "B", "C"}, {1, 2}} { |
683 | 688 | // if err := f.SetSheetRow("Sheet1", fmt.Sprintf("A%d", idx+1), &row); err != nil { |
684 | 689 | // fmt.Println(err) |
@@ -1044,6 +1049,11 @@ func setRichText(runs []RichTextRun) ([]xlsxR, error) { |
1044 | 1049 | // |
1045 | 1050 | // func main() { |
1046 | 1051 | // f := excelize.NewFile() |
| 1052 | +// defer func() { |
| 1053 | +// if err := f.Close(); err != nil { |
| 1054 | +// fmt.Println(err) |
| 1055 | +// } |
| 1056 | +// }() |
1047 | 1057 | // if err := f.SetRowHeight("Sheet1", 1, 35); err != nil { |
1048 | 1058 | // fmt.Println(err) |
1049 | 1059 | // return |
@@ -1395,39 +1405,39 @@ func (f *File) mergeCellsParser(ws *xlsxWorksheet, cell string) (string, error) |
1395 | 1405 |
|
1396 | 1406 | // checkCellInRangeRef provides a function to determine if a given cell reference |
1397 | 1407 | // in a range. |
1398 | | -func (f *File) checkCellInRangeRef(cell, reference string) (bool, error) { |
| 1408 | +func (f *File) checkCellInRangeRef(cell, rangeRef string) (bool, error) { |
1399 | 1409 | col, row, err := CellNameToCoordinates(cell) |
1400 | 1410 | if err != nil { |
1401 | 1411 | return false, err |
1402 | 1412 | } |
1403 | 1413 |
|
1404 | | - if rng := strings.Split(reference, ":"); len(rng) != 2 { |
| 1414 | + if rng := strings.Split(rangeRef, ":"); len(rng) != 2 { |
1405 | 1415 | return false, err |
1406 | 1416 | } |
1407 | | - coordinates, err := rangeRefToCoordinates(reference) |
| 1417 | + coordinates, err := rangeRefToCoordinates(rangeRef) |
1408 | 1418 | if err != nil { |
1409 | 1419 | return false, err |
1410 | 1420 | } |
1411 | 1421 |
|
1412 | | - return cellInRef([]int{col, row}, coordinates), err |
| 1422 | + return cellInRange([]int{col, row}, coordinates), err |
1413 | 1423 | } |
1414 | 1424 |
|
1415 | | -// cellInRef provides a function to determine if a given range is within a |
| 1425 | +// cellInRange provides a function to determine if a given range is within a |
1416 | 1426 | // range. |
1417 | | -func cellInRef(cell, ref []int) bool { |
| 1427 | +func cellInRange(cell, ref []int) bool { |
1418 | 1428 | return cell[0] >= ref[0] && cell[0] <= ref[2] && cell[1] >= ref[1] && cell[1] <= ref[3] |
1419 | 1429 | } |
1420 | 1430 |
|
1421 | 1431 | // isOverlap find if the given two rectangles overlap or not. |
1422 | 1432 | func isOverlap(rect1, rect2 []int) bool { |
1423 | | - return cellInRef([]int{rect1[0], rect1[1]}, rect2) || |
1424 | | - cellInRef([]int{rect1[2], rect1[1]}, rect2) || |
1425 | | - cellInRef([]int{rect1[0], rect1[3]}, rect2) || |
1426 | | - cellInRef([]int{rect1[2], rect1[3]}, rect2) || |
1427 | | - cellInRef([]int{rect2[0], rect2[1]}, rect1) || |
1428 | | - cellInRef([]int{rect2[2], rect2[1]}, rect1) || |
1429 | | - cellInRef([]int{rect2[0], rect2[3]}, rect1) || |
1430 | | - cellInRef([]int{rect2[2], rect2[3]}, rect1) |
| 1433 | + return cellInRange([]int{rect1[0], rect1[1]}, rect2) || |
| 1434 | + cellInRange([]int{rect1[2], rect1[1]}, rect2) || |
| 1435 | + cellInRange([]int{rect1[0], rect1[3]}, rect2) || |
| 1436 | + cellInRange([]int{rect1[2], rect1[3]}, rect2) || |
| 1437 | + cellInRange([]int{rect2[0], rect2[1]}, rect1) || |
| 1438 | + cellInRange([]int{rect2[2], rect2[1]}, rect1) || |
| 1439 | + cellInRange([]int{rect2[0], rect2[3]}, rect1) || |
| 1440 | + cellInRange([]int{rect2[2], rect2[3]}, rect1) |
1431 | 1441 | } |
1432 | 1442 |
|
1433 | 1443 | // parseSharedFormula generate dynamic part of shared formula for target cell |
|
0 commit comments