@@ -41,6 +41,7 @@ func (f *File) mergeCellsParser(xlsx *xlsxWorksheet, axis string) string {
41
41
// []byte
42
42
// time.Duration
43
43
// time.Time
44
+ // bool
44
45
// nil
45
46
//
46
47
// Note that default date format is m/d/yy h:mm of time.Time type value. You can
@@ -63,6 +64,8 @@ func (f *File) SetCellValue(sheet, axis string, value interface{}) {
63
64
f .setDefaultTimeStyle (sheet , axis , 22 )
64
65
case nil :
65
66
f .SetCellStr (sheet , axis , "" )
67
+ case bool :
68
+ f .SetCellBool (sheet , axis , bool (value .(bool )))
66
69
default :
67
70
f .setCellIntValue (sheet , axis , value )
68
71
}
@@ -96,6 +99,34 @@ func (f *File) setCellIntValue(sheet, axis string, value interface{}) {
96
99
}
97
100
}
98
101
102
+ // SetCellBool provides function to set bool type value of a cell by given
103
+ // worksheet name, cell coordinates and cell value.
104
+ func (f * File ) SetCellBool (sheet , axis string , value bool ) {
105
+ xlsx := f .workSheetReader (sheet )
106
+ axis = f .mergeCellsParser (xlsx , axis )
107
+ col := string (strings .Map (letterOnlyMapF , axis ))
108
+ row , err := strconv .Atoi (strings .Map (intOnlyMapF , axis ))
109
+ if err != nil {
110
+ return
111
+ }
112
+ xAxis := row - 1
113
+ yAxis := TitleToNumber (col )
114
+
115
+ rows := xAxis + 1
116
+ cell := yAxis + 1
117
+
118
+ completeRow (xlsx , rows , cell )
119
+ completeCol (xlsx , rows , cell )
120
+
121
+ xlsx .SheetData .Row [xAxis ].C [yAxis ].S = f .prepareCellStyle (xlsx , cell , xlsx .SheetData .Row [xAxis ].C [yAxis ].S )
122
+ xlsx .SheetData .Row [xAxis ].C [yAxis ].T = "b"
123
+ if value {
124
+ xlsx .SheetData .Row [xAxis ].C [yAxis ].V = "1"
125
+ } else {
126
+ xlsx .SheetData .Row [xAxis ].C [yAxis ].V = "0"
127
+ }
128
+ }
129
+
99
130
// GetCellValue provides function to get formatted value from cell by given
100
131
// worksheet name and axis in XLSX file. If it is possible to apply a format to
101
132
// the cell value, it will do so, if not then an error will be returned, along
0 commit comments