简体   繁体   中英

Cannot place shape in Chart tab with Aspose.Cells

I'm trying to insert a watermark on a Workbook, but I can't place the watermark on chart elements. This is my code:

Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
            text, "Arial Black", 50, true, false
            , 0, 200, 0, 100, 97 * (text.Count(x => x == '\n') + 1), 49 * 25);

            MsoFillFormat wordArtFormat = wordart.FillFormat;
            wordArtFormat.ForeColor = System.Drawing.Color.Black;
            wordart.RotationAngle = -40;
            wordart.IsTextWrapped = false;
            wordArtFormat.Transparency = 1 - 0.7;
            wordart.X = 000;
            wordart.Y = 300;

            wordart.ZOrderPosition = 30;
            MsoLineFormat lineFormat = wordart.LineFormat;
            lineFormat.IsVisible = false;

            foreach (var chart in sheet.Charts)
            {

                Aspose.Cells.Drawing.Shape wordart2 = chart.Shapes.AddTextEffectInChart(MsoPresetTextEffect.TextEffect1,
                    text, "Arial Black", 50, true, false
                    , 0, 0, 97 * (text.Count(x => x == '\n') + 1), 49 * 25);

                MsoFillFormat wordArtFormat2 = wordart2.FillFormat;
                wordArtFormat2.ForeColor = System.Drawing.Color.Black;
                wordart2.RotationAngle = -40;
                wordart2.IsTextWrapped = false;
                wordArtFormat2.Transparency = 1 - 0.7;
                wordart2.X = 000;
                wordart2.Y = 300;

                wordart2.ZOrderPosition = 30;
                MsoLineFormat lineFormat2 = wordart2.LineFormat;
                lineFormat2.IsVisible = false;


            }

The watermark works fine with the Spreadsheets, but nothing shows up on Charts.

Update - 2

This issue has been fixed in June release ie 18.6 which will be published on NuGet around 15-20th June, 2018. However, you can download the HotFix from the following link.


Update - 1

This issue was occurring because of the following line.

wordart2.RotationAngle = -40; 

If it is removed, everything works fine.

When we set the rotation of the shape, we have to re-calculate the position of the shape and there is a problem when we re-calculate the position of the shape in the chart.


Note: I am working as Developer Evangelist at Aspose

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM