summaryrefslogtreecommitdiff
path: root/col.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2022-03-24 00:19:30 +0800
committerxuri <xuri.me@gmail.com>2022-03-24 00:19:30 +0800
commit8a335225c705232fe1174755a1b1ea475456b864 (patch)
tree7bae0af1f1ce3459ad429d4fbca60a5e9b35a0e1 /col.go
parent139ee4c4b0c86dffbdca77da346e85a4cbd97b0c (diff)
Format code, update documentation and remove exported variable `XMLHeaderByte`
Diffstat (limited to 'col.go')
-rw-r--r--col.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/col.go b/col.go
index 827d727..ee1a407 100644
--- a/col.go
+++ b/col.go
@@ -40,8 +40,7 @@ type Cols struct {
sheetXML []byte
}
-// GetCols return all the columns in a sheet by given worksheet name (case
-// sensitive). For example:
+// GetCols return all the columns in a sheet by given worksheet name (case-sensitive). For example:
//
// cols, err := f.GetCols("Sheet1")
// if err != nil {
@@ -240,20 +239,18 @@ func (f *File) Cols(sheet string) (*Cols, error) {
// visible, err := f.GetColVisible("Sheet1", "D")
//
func (f *File) GetColVisible(sheet, col string) (bool, error) {
- visible := true
colNum, err := ColumnNameToNumber(col)
if err != nil {
- return visible, err
+ return true, err
}
-
ws, err := f.workSheetReader(sheet)
if err != nil {
return false, err
}
if ws.Cols == nil {
- return visible, err
+ return true, err
}
-
+ visible := true
for c := range ws.Cols.Col {
colData := &ws.Cols.Col[c]
if colData.Min <= colNum && colNum <= colData.Max {
@@ -455,12 +452,12 @@ func (f *File) SetColStyle(sheet, columns string, styleID int) error {
// f := excelize.NewFile()
// err := f.SetColWidth("Sheet1", "A", "H", 20)
//
-func (f *File) SetColWidth(sheet, startcol, endcol string, width float64) error {
- min, err := ColumnNameToNumber(startcol)
+func (f *File) SetColWidth(sheet, startCol, endCol string, width float64) error {
+ min, err := ColumnNameToNumber(startCol)
if err != nil {
return err
}
- max, err := ColumnNameToNumber(endcol)
+ max, err := ColumnNameToNumber(endCol)
if err != nil {
return err
}
@@ -502,7 +499,7 @@ func (f *File) SetColWidth(sheet, startcol, endcol string, width float64) error
// flatCols provides a method for the column's operation functions to flatten
// and check the worksheet columns.
func flatCols(col xlsxCol, cols []xlsxCol, replacer func(fc, c xlsxCol) xlsxCol) []xlsxCol {
- fc := []xlsxCol{}
+ var fc []xlsxCol
for i := col.Min; i <= col.Max; i++ {
c := deepcopy.Copy(col).(xlsxCol)
c.Min, c.Max = i, i
@@ -547,7 +544,7 @@ func flatCols(col xlsxCol, cols []xlsxCol, replacer func(fc, c xlsxCol) xlsxCol)
// | | | (x2,y2)|
// +-----+------------+------------+
//
-// Example of an object that covers some of the area from cell A1 to B2.
+// Example of an object that covers some area from cell A1 to B2.
//
// Based on the width and height of the object we need to calculate 8 vars:
//