@@ -694,9 +694,9 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) {
694694//
695695// Set chart size by dimension property. The dimension property is optional. The default width is 480, and height is 290.
696696//
697- // combo: Specifies the create a chart that combines two art types in a single
698- // chart. For example, create a clustered column - line chart with data
699- // Sheet1!$E$1:$L$15:
697+ // combo: Specifies the create a chart that combines two or more chart types
698+ // in a single chart. For example, create a clustered column - line chart with
699+ // data Sheet1!$E$1:$L$15:
700700//
701701// package main
702702//
@@ -782,10 +782,11 @@ func (f *File) DeleteChart(sheet, cell string) (err error) {
782782 }
783783 drawingXML := strings .Replace (f .getSheetRelationshipsTargetByID (sheet , ws .Drawing .RID ), ".." , "xl" , - 1 )
784784 wsDr , _ = f .drawingParser (drawingXML )
785- for idx , anchor := range wsDr .TwoCellAnchor {
786- if err = nil ; anchor . From != nil && anchor .Pic == nil {
787- if anchor . From .Col == col && anchor .From .Row == row {
785+ for idx := 0 ; idx < len ( wsDr .TwoCellAnchor ); idx ++ {
786+ if err = nil ; wsDr . TwoCellAnchor [ idx ]. From != nil && wsDr . TwoCellAnchor [ idx ] .Pic == nil {
787+ if wsDr . TwoCellAnchor [ idx ]. From .Col == col && wsDr . TwoCellAnchor [ idx ] .From .Row == row {
788788 wsDr .TwoCellAnchor = append (wsDr .TwoCellAnchor [:idx ], wsDr .TwoCellAnchor [idx + 1 :]... )
789+ idx --
789790 }
790791 }
791792 }
@@ -795,26 +796,18 @@ func (f *File) DeleteChart(sheet, cell string) (err error) {
795796// deleteChart provides a function to delete chart graphic frame by given by
796797// given coordinates.
797798func (f * File ) deleteChart (col , row int , drawingXML string , wsDr * xlsxWsDr ) (err error ) {
798- var (
799- deWsDr * decodeWsDr
800- deTwoCellAnchor * decodeTwoCellAnchor
801- )
802- deWsDr = new (decodeWsDr )
803- if err = f .xmlNewDecoder (bytes .NewReader (namespaceStrictToTransitional (f .readXML (drawingXML )))).
804- Decode (deWsDr ); err != nil && err != io .EOF {
805- err = fmt .Errorf ("xml decode error: %s" , err )
806- return
807- }
808- for idx , anchor := range deWsDr .TwoCellAnchor {
799+ var deTwoCellAnchor * decodeTwoCellAnchor
800+ for idx := 0 ; idx < len (wsDr .TwoCellAnchor ); idx ++ {
809801 deTwoCellAnchor = new (decodeTwoCellAnchor )
810- if err = f .xmlNewDecoder (bytes .NewReader ([]byte ("<decodeTwoCellAnchor>" + anchor . Content + "</decodeTwoCellAnchor>" ))).
802+ if err = f .xmlNewDecoder (bytes .NewReader ([]byte ("<decodeTwoCellAnchor>" + wsDr . TwoCellAnchor [ idx ]. GraphicFrame + "</decodeTwoCellAnchor>" ))).
811803 Decode (deTwoCellAnchor ); err != nil && err != io .EOF {
812804 err = fmt .Errorf ("xml decode error: %s" , err )
813805 return
814806 }
815807 if err = nil ; deTwoCellAnchor .From != nil && deTwoCellAnchor .Pic == nil {
816- if anchor .From .Col == col && anchor .From .Row == row {
808+ if deTwoCellAnchor .From .Col == col && deTwoCellAnchor .From .Row == row {
817809 wsDr .TwoCellAnchor = append (wsDr .TwoCellAnchor [:idx ], wsDr .TwoCellAnchor [idx + 1 :]... )
810+ idx --
818811 }
819812 }
820813 }
0 commit comments