Esempio n. 1
0
        static void ExportChart(string strFile)
        {
            Application app = GetApp();

            if (app == null)
            {
                throw new Exception("先打开excel");
            }

            Workbook workbook = app.Workbooks.Open(strFile);

            foreach (Worksheet sheet in workbook.Sheets)
            {
                foreach (Shape shape in sheet.Shapes)
                {
                    MsoShapeType typ = MsoShapeType.msoShapeTypeMixed;
                    try
                    {
                        typ = shape.Type;
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                    if (typ == MsoShapeType.msoChart)
                    {
                        ExportChart(shape, strFile);
                    }
                }
            }
            workbook.Close(MsoTriState.msoFalse);
        }
Esempio n. 2
0
        public List <Shape> GetShapesWithTypeAndRule(MsoShapeType type, Regex nameRule)
        {
            var shapes         = _slide.Shapes.Cast <Shape>().ToList();
            var matchingShapes = shapes.Where(current => current.Type == type &&
                                              nameRule.IsMatch(current.Name)).ToList();

            return(matchingShapes);
        }
Esempio n. 3
0
        //Перевод типа фигуры в строку
        public static string ToEnglish(this MsoShapeType type)
        {
            switch (type)
            {
            case MsoShapeType.msoTextBox:
                return("TextBox");

            case MsoShapeType.msoGroup:
                return("Group");
            }
            return("");
        }
        //bracket. parenthesis = 괄호 의미 단어
        public static string MsoShapeTypeToString(MsoShapeType type, bool WithFormat = true)
        {
            string str = "오브젝트";

            switch (type)
            {
            case MsoShapeType.msoAutoShape: str = "도형"; break;

            case MsoShapeType.msoCanvas: str = "캔버스"; break;

            case MsoShapeType.msoCallout: str = "호출"; break;

            case MsoShapeType.msoChart: str = "차트"; break;

            case MsoShapeType.msoDiagram: str = "다이어그램"; break;

            case MsoShapeType.msoComment: str = "코멘트"; break;

            case MsoShapeType.msoContentApp: str = "컨텐츠 앱"; break;

            case MsoShapeType.msoOLEControlObject: str = "OLE 컨트롤"; break;

            case MsoShapeType.msoFreeform: str = "자유형"; break;

            case MsoShapeType.msoGroup: str = "그룹"; break;

            case MsoShapeType.msoLine: str = "선"; break;

            case MsoShapeType.msoMedia: str = "미디어"; break;

            case MsoShapeType.msoPicture: str = "사진"; break;

            case MsoShapeType.msoPlaceholder: str = "위치 홀더"; break;

            case MsoShapeType.msoSmartArt: str = "스마트 아트"; break;

            case MsoShapeType.msoTable: str = "표"; break;

            case MsoShapeType.msoTextBox: str = "텍스트 박스"; break;

            case MsoShapeType.msoTextEffect: str = "텍스트 효과"; break;
            }
            if (WithFormat)
            {
                return($"({str})");
            }
            return(str);
        }
        public List<Shape> GetShapesWithTypeAndRule(MsoShapeType type, Regex nameRule)
        {
            var shapes = _slide.Shapes.Cast<Shape>().ToList();
            var matchingShapes = shapes.Where(current => current.Type == type &&
                                              nameRule.IsMatch(current.Name)).ToList();

            return matchingShapes;
        }
Esempio n. 6
0
        public static ShapeRange GetShapesWhenTypeNotMatches(PowerPointSlide slide, ShapeRange shapes, MsoShapeType type)
        {
            List <Shape> newShapeList = new List <Shape>();

            foreach (Shape shape in shapes)
            {
                if (shape.Type != type)
                {
                    newShapeList.Add(shape);
                }
            }
            return(slide.ToShapeRange(newShapeList));
        }
Esempio n. 7
0
        public void tsc_loadtheme()
        {
            System.Text.StringBuilder specification = new System.Text.StringBuilder();
            PowerPoint.Shape          selShape      = ppApp.ActiveWindow.Selection.ShapeRange[1];


            MsoShapeType shpType = selShape.Type;

            if (selShape.Type == MsoShapeType.msoTable)
            {
                float borderWidth = selShape.Table.Rows[1].Cells[1].Borders[PowerPoint.PpBorderType.ppBorderRight].Weight;
            }
            else
            {
                foreach (PowerPoint.Shape shp in ppApp.ActiveWindow.Selection.ShapeRange)
                {
                    MsoTriState vstatus    = shp.Line.Visible;                                                     //LineVisible
                    MsoTriState fillStatus = shp.Fill.Visible;                                                     //FillVisible
                                                                                                                   //str fillColor = shp.Fill.ForeColor.RGB;               //FillColor-----------------------Not
                    float       fillTrasn = shp.Fill.Transparency;                                                 //FillTransparency
                    MsoTriState sVisible  = shp.Shadow.Visible;                                                    //ShadowVisible
                    float       sleft     = shp.Left;                                                              //ShapeLeft
                    float       stop      = shp.Top;                                                               //ShapeTop
                    float       swidth    = shp.Width;                                                             //ShapeWidth
                    float       shpHeight = shp.Height;                                                            //ShapeHeight
                    float       rot       = shp.Rotation;                                                          //Rotaion
                    MsoTriState lrvalue   = shp.LockAspectRatio;                                                   //LockAspectRatio

                    MsoTextOrientation    txtOrientation = shp.TextFrame.Orientation;                              //Orientation
                    MsoVerticalAnchor     txtAnchor      = shp.TextFrame.VerticalAnchor;                           //VerticalAnchor
                    PowerPoint.PpAutoSize autosize       = shp.TextFrame.AutoSize;                                 //AutoSize
                    float       mgleft      = shp.TextFrame.MarginLeft;                                            //MarginLeft
                    float       mgRight     = shp.TextFrame.MarginLeft;                                            //MarginRight
                    float       mgtop       = shp.TextFrame.MarginTop;                                             //MarginTop
                    float       mgbottom    = shp.TextFrame.MarginBottom;                                          //MarginBottom
                    MsoTriState wWrap       = shp.TextFrame.WordWrap;                                              //WordWrap
                    string      dtext       = shp.TextFrame.TextRange.Text;                                        //DefaultText
                    string      fname       = shp.TextFrame.TextRange.Font.Name;                                   //FontName
                    MsoTriState txbold      = shp.TextFrame.TextRange.Font.Bold;                                   //Bold
                    MsoTriState txItalics   = shp.TextFrame.TextRange.Font.Italic;                                 //Italics
                    MsoTriState txUnderline = shp.TextFrame.TextRange.Font.Underline;                              //Underline
                    float       txsize      = shp.TextFrame.TextRange.Font.Size;                                   //FontSize
                                                                                                                   //FontColor
                    PowerPoint.ShadowFormat shadow = shp.Shadow;                                                   //Shadow
                                                                                                                   //PowerPoint.PpChangeCase txcase = shp.TextFrame.TextRange.ChangeCase;                //Case
                    PowerPoint.BulletFormat         txbuttlet = shp.TextFrame.TextRange.ParagraphFormat.Bullet;    //ParagraphBullet
                    PowerPoint.PpParagraphAlignment txtAlig   = shp.TextFrame.TextRange.ParagraphFormat.Alignment; //ParagraphAlignment
                    MsoTriState hPun = shp.TextFrame.TextRange.ParagraphFormat.HangingPunctuation;                 //ParagraphHangingPunctuation
                    float       psb  = shp.TextFrame.TextRange.ParagraphFormat.SpaceBefore;                        //ParagraphSpaceBefore
                    float       psa  = shp.TextFrame.TextRange.ParagraphFormat.SpaceAfter;                         //ParagraphSpaceAfter
                    float       psw  = shp.TextFrame.TextRange.ParagraphFormat.SpaceWithin;                        //ParagraphSpaceWithin
                    float       rlfm = shp.TextFrame.Ruler.Levels[1].FirstMargin;                                  //RulerLevel1FirstMargin
                    float       rllm = shp.TextFrame.Ruler.Levels[1].LeftMargin;                                   ////RulerLevel1LeftMargin
                    for (int i = 1; i <= shp.TextFrame.TextRange.Paragraphs().Count; i++)
                    {
                        string paraStr   = shp.TextFrame.TextRange.Paragraphs(i).Text;
                        int    indentVal = shp.TextFrame.TextRange.Paragraphs(i).IndentLevel;
                    }

                    specification.Append("LineVisible :" + vstatus + Environment.NewLine + "FillVisible :" + fillStatus + Environment.NewLine + "FillTransparency :" + fillTrasn + Environment.NewLine);
                    specification.Append("ShapeLeft :" + sleft + Environment.NewLine + "ShapeTop :" + stop + Environment.NewLine + "ShapeWeight :" + swidth + Environment.NewLine + "ShapeHeight :" + shpHeight + Environment.NewLine);


                    specification.Append("Rotaion :" + rot + Environment.NewLine + "LockAspectRatio :" + lrvalue + Environment.NewLine + "Orientation :" + txtOrientation + Environment.NewLine + "VerticalAnchor :" + txtAnchor + Environment.NewLine);
                    specification.Append("AutoSize :" + autosize + Environment.NewLine + "MarginLeft :" + mgleft + Environment.NewLine + "MarginRight :" + mgRight + Environment.NewLine + "MarginTop :" + mgtop + Environment.NewLine);
                    specification.Append("MarginBottom :" + mgbottom + Environment.NewLine + "WordWrap :" + wWrap + Environment.NewLine + "DefaultText :" + dtext + Environment.NewLine + "FontName :" + fname + Environment.NewLine);
                    specification.Append("Bold :" + txbold + Environment.NewLine + "Italics :" + txItalics + Environment.NewLine + "Underline :" + txUnderline + Environment.NewLine + "FontSize :" + txsize + Environment.NewLine);
                    specification.Append("Shadow :" + shadow + Environment.NewLine + "ParagraphBullet :" + txbuttlet + Environment.NewLine + "ParagraphAlignment :" + txtAlig + Environment.NewLine + "ParagraphHangingPunctuation :" + hPun + Environment.NewLine);
                    specification.Append("ParagraphSpaceBefore :" + psb + Environment.NewLine + "ParagraphSpaceAfter :" + psa + Environment.NewLine + "ParagraphSpaceWithin :" + psw + Environment.NewLine + "RulerLevel1FirstMargin :" + rlfm + Environment.NewLine);
                    specification.Append("RulerLevel1LeftMargin :" + rllm);
                    PPTAttribute.saveSpacification(specification, shp.Name);
                }
            }
        }
Esempio n. 8
0
        public static BitmapImage GetResourceIcon(MsoShapeType type)
        {
            string URLList   = "Component Icon/";
            string ImageName = "";

            switch (type)
            {
            case MsoShapeType.msoAutoShape:
                ImageName = "shapeicon_s";
                break;

            case MsoShapeType.msoChart:
                ImageName = "charticon_s";
                break;

            case MsoShapeType.msoGroup:
                ImageName = "groupicon_s";
                break;

            case MsoShapeType.msoPicture:
                ImageName = "pictureicon_s";
                break;

            case MsoShapeType.msoCanvas:
                ImageName = "canvasicon_s";
                break;

            case MsoShapeType.msoDiagram:
                ImageName = "diagramicon_s";
                break;

            case MsoShapeType.msoTextEffect:
                ImageName = "Effecticon_s";
                break;

            case MsoShapeType.msoFreeform:
                ImageName = "Freeformicon_s";
                break;

            case MsoShapeType.msoLinkedOLEObject:
            case MsoShapeType.msoLinkedPicture:
                ImageName = "hyperlinkicon_s";
                break;

            case MsoShapeType.msoSmartArt:
                ImageName = "smartarticon_s";
                break;

            case MsoShapeType.msoTable:
                ImageName = "tableicon_s";
                break;

            case MsoShapeType.msoTextBox:
                ImageName = "textboxicon_s";
                break;

            case MsoShapeType.msoOLEControlObject:
                ImageName = "olectrlobjicon_s";
                break;

            case MsoShapeType.msoEmbeddedOLEObject:
                ImageName = "objecticon_s";
                break;

            case MsoShapeType.msoLine:
                ImageName = "lineicon_s";
                break;

            case MsoShapeType.msoMedia:
                ImageName = "mediaicon_s";
                break;

            case MsoShapeType.msoPlaceholder:
                //TODO : Add PlaceHolder Icon
                ImageName = "placeholdericon_s";
                break;

            default:
                ImageName = "objecticon_s";
                break;
            }

            return(GetResourceImage(URLList + ImageName + ".png"));
        }