@@ -548,9 +548,10 @@ func AddFormControl(idx int, sheet *C.char, opts *C.struct_FormControl) *C.char
548548 return C .CString (emptyString )
549549}
550550
551- // Add picture in a sheet by given picture format set (such as offset, scale,
552- // aspect ratio setting and print settings) and file path, supported image
553- // types: BMP, EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
551+ // AddPicture add picture in a sheet by given picture format set (such as
552+ // offset, scale, aspect ratio setting and print settings) and file path,
553+ // supported image types: BMP, EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF,
554+ // WMF, and WMZ.
554555//
555556//export AddPicture
556557func AddPicture (idx int , sheet , cell , name * C.char , opts * C.struct_GraphicOptions ) * C.char {
@@ -1189,6 +1190,29 @@ func GetColWidth(idx int, sheet, col *C.char) C.struct_Float64ErrorResult {
11891190 return C.struct_Float64ErrorResult {val : C .double (val ), err : C .CString (emptyString )}
11901191}
11911192
1193+ // GetComments retrieves all comments in a worksheet by given worksheet name.
1194+ //
1195+ //export GetComments
1196+ func GetComments (idx int , sheet * C.char ) C.struct_GetCommentsResult {
1197+ f , ok := files .Load (idx )
1198+ if ! ok {
1199+ return C.struct_GetCommentsResult {Err : C .CString (errFilePtr )}
1200+ }
1201+ comments , err := f .(* excelize.File ).GetComments (C .GoString (sheet ))
1202+ if err != nil {
1203+ return C.struct_GetCommentsResult {Err : C .CString (err .Error ())}
1204+ }
1205+ cArray := C .malloc (C .size_t (len (comments )) * C .size_t (unsafe .Sizeof (C.struct_Comment {})))
1206+ for i , r := range comments {
1207+ cVal , err := goValueToC (reflect .ValueOf (r ), reflect .ValueOf (& C.struct_Comment {}))
1208+ if err != nil {
1209+ return C.struct_GetCommentsResult {Err : C .CString (err .Error ())}
1210+ }
1211+ * (* C .struct_Comment )(unsafe .Pointer (uintptr (unsafe .Pointer (cArray )) + uintptr (i )* unsafe .Sizeof (C.struct_Comment {}))) = cVal .Elem ().Interface ().(C.struct_Comment )
1212+ }
1213+ return C.struct_GetCommentsResult {CommentsLen : C .int (len (comments )), Comments : (* C .struct_Comment )(cArray ), Err : C .CString (emptyString )}
1214+ }
1215+
11921216// GetDefaultFont provides the default font name currently set in the
11931217// workbook. The spreadsheet generated by excelize default font is Calibri.
11941218//
@@ -1302,6 +1326,56 @@ func GetSheetIndex(idx int, sheet *C.char) C.struct_IntErrorResult {
13021326 return C.struct_IntErrorResult {val : C .int (idx ), err : C .CString (emptyString )}
13031327}
13041328
1329+ // GetSheetList provides a function to get worksheets, chart sheets, and
1330+ // dialog sheets name list of the workbook.
1331+ //
1332+ //export GetSheetList
1333+ func GetSheetList (idx int ) C.struct_StringArrayErrorResult {
1334+ f , ok := files .Load (idx )
1335+ if ! ok {
1336+ return C.struct_StringArrayErrorResult {Err : C .CString (errFilePtr )}
1337+ }
1338+ result := f .(* excelize.File ).GetSheetList ()
1339+ cArray := C .malloc (C .size_t (len (result )) * C .size_t (unsafe .Sizeof (uintptr (0 ))))
1340+ for i , v := range result {
1341+ * (* unsafe .Pointer )(unsafe .Pointer (uintptr (unsafe .Pointer (cArray )) + uintptr (i )* unsafe .Sizeof (uintptr (0 )))) = unsafe .Pointer (C .CString (v ))
1342+ }
1343+ return C.struct_StringArrayErrorResult {ArrLen : C .int (len (result )), Arr : (* * C .char )(cArray ), Err : C .CString (emptyString )}
1344+ }
1345+
1346+ // GetSheetMap provides a function to get worksheets, chart sheets, dialog
1347+ // sheets ID and name map of the workbook.
1348+ //
1349+ //export GetSheetMap
1350+ func GetSheetMap (idx int ) C.struct_GetSheetMapResult {
1351+ type IntStringResult struct {
1352+ K int
1353+ V string
1354+ }
1355+ type GetSheetMapResult struct {
1356+ Arr []IntStringResult
1357+ Err string
1358+ }
1359+ var result GetSheetMapResult
1360+ f , ok := files .Load (idx )
1361+ if ! ok {
1362+ return C.struct_GetSheetMapResult {
1363+ Err : C .CString (errFilePtr ),
1364+ }
1365+ }
1366+ for k , v := range f .(* excelize.File ).GetSheetMap () {
1367+ result .Arr = append (result .Arr , IntStringResult {K : k , V : v })
1368+ }
1369+
1370+ cVal , err := goValueToC (reflect .ValueOf (result ), reflect .ValueOf (& C.struct_GetSheetMapResult {}))
1371+ if err != nil {
1372+ return C.struct_GetSheetMapResult {Err : C .CString (err .Error ())}
1373+ }
1374+ ret := cVal .Elem ().Interface ().(C.struct_GetSheetMapResult )
1375+ ret .Err = C .CString (emptyString )
1376+ return ret
1377+ }
1378+
13051379// GetSheetName provides a function to get the sheet name by the given worksheet index.
13061380// If the given worksheet index is invalid, it will return an error.
13071381//
0 commit comments