示例#1
0
        static void Main(string[] args)
        {
            //Instantiate a new Workbook
            Workbook workbook = new Workbook();

            //Get the first default sheet
            Worksheet sheet = workbook.Worksheets[0];

            //Add Watermark
            Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
                                                                            "CONFIDENTIAL", "Arial Black", 50, false, true
                                                                            , 18, 8, 1, 1, 130, 800);

            //Get the fill format of the word art
            MsoFillFormat wordArtFormat = wordart.FillFormat;

            //Set the color
            wordArtFormat.ForeColor = System.Drawing.Color.Red;

            //Set the transparency
            wordArtFormat.Transparency = 0.9;

            //Make the line invisible
            MsoLineFormat lineFormat = wordart.LineFormat;

            lineFormat.IsVisible = false;

            //Save the file
            workbook.Save("Watermarkt_Test.xls");
        }
示例#2
0
        public static void Main(string[] args)
        {
            //ExStart:1
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate a new Workbook
            Workbook workbook = new Workbook();

            //Get the first default sheet
            Worksheet sheet = workbook.Worksheets[0];

            //Add Watermark
            Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
                                                                            "CONFIDENTIAL", "Arial Black", 50, false, true
                                                                            , 18, 8, 1, 1, 130, 800);

            //Get the fill format of the word art
            MsoFillFormat wordArtFormat = wordart.FillFormat;

            //Set the color
            wordArtFormat.ForeColor = System.Drawing.Color.Red;

            //Set the transparency
            wordArtFormat.Transparency = 0.9;

            //Make the line invisible
            MsoLineFormat lineFormat = wordart.LineFormat;

            lineFormat.IsVisible = false;

            //Save the file
            workbook.Save(dataDir + "Watermark_Test.out.xls");
            //ExEnd:1
        }
示例#3
0
        /// <summary>
        /// 在sheet中添加水印
        /// </summary>
        /// <param name="worksheet"></param>
        /// <param name="effect"></param>
        /// <param name="text"></param>
        /// <param name="fontName"></param>
        /// <param name="size"></param>
        /// <param name="fontBold"></param>
        /// <param name="fontItalic"></param>
        /// <param name="upperLeftRow"></param>
        /// <param name="top"></param>
        /// <param name="upperLeftColumn"></param>
        /// <param name="left"></param>
        /// <param name="height"></param>
        /// <param name="width"></param>
        static void AddWaterMarkInSheet(Worksheet worksheet, MsoPresetTextEffect effect, string text,
                                        string fontName, int size, bool fontBold, bool fontItalic, int upperLeftRow,
                                        int top, int upperLeftColumn, int left, int height, int width)
        {
            Aspose.Cells.Drawing.Shape wordart = worksheet.Shapes.AddTextEffect(
                effect, text, fontName, size, fontBold, fontItalic, upperLeftRow, top, upperLeftColumn, left, height, width);

            MsoFillFormat wordArtFormat = wordart.FillFormat;

            wordArtFormat.ForeColor    = System.Drawing.Color.Red;
            wordArtFormat.Transparency = 0.9;
            MsoLineFormat lineFormat = wordart.LineFormat;

            lineFormat.IsVisible = false;
            wordart.SetLockedProperty(ShapeLockType.Selection, true);
            wordart.SetLockedProperty(ShapeLockType.ShapeType, true);
            wordart.SetLockedProperty(ShapeLockType.Move, true);
            wordart.SetLockedProperty(ShapeLockType.Resize, true);
            wordart.SetLockedProperty(ShapeLockType.Text, true);
        }
示例#4
0
        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string FileName = FilePath + "Locking WordArt Watermark.xlsx";

            //Instantiate a new Workbook
            Workbook workbook = new Workbook();

            //Get the first default sheet
            Worksheet sheet = workbook.Worksheets[0];

            //Add Watermark
            Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
                                                                            "CONFIDENTIAL", "Arial Black", 50, false, true
                                                                            , 18, 8, 1, 1, 130, 800);

            //Lock Shape Aspects
            wordart.IsLocked = true;
            wordart.SetLockedProperty(ShapeLockType.Selection, true);
            wordart.SetLockedProperty(ShapeLockType.ShapeType, true);
            wordart.SetLockedProperty(ShapeLockType.Move, true);
            wordart.SetLockedProperty(ShapeLockType.Resize, true);
            wordart.SetLockedProperty(ShapeLockType.Text, true);

            //Get the fill format of the word art
            MsoFillFormat wordArtFormat = wordart.FillFormat;

            //Set the color
            wordArtFormat.ForeColor = Color.Red;

            //Set the transparency
            wordArtFormat.Transparency = 0.9;

            //Make the line invisible
            MsoLineFormat lineFormat = wordart.LineFormat;

            lineFormat.IsVisible = false;

            //Save the file
            workbook.Save(FileName);
        }
示例#5
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate a new Workbook.
            Workbook workbook = new Workbook();

            //Get the first worksheet in the book.
            Worksheet worksheet = workbook.Worksheets[0];

            //Add a new textbox to the collection.
            int textboxIndex = worksheet.TextBoxes.Add(2, 1, 160, 200);

            //Get the textbox object.
            Aspose.Cells.Drawing.TextBox textbox0 = worksheet.TextBoxes[textboxIndex];

            //Fill the text.
            textbox0.Text = "ASPOSE______The .NET & JAVA Component Publisher!";

            //Get the textbox text frame.
            MsoTextFrame textframe0 = textbox0.TextFrame;

            //Set the textbox to adjust it according to its contents.
            textframe0.AutoSize = true;

            //Set the placement.
            textbox0.Placement = PlacementType.FreeFloating;

            //Set the font color.
            textbox0.Font.Color = Color.Blue;

            //Set the font to bold.
            textbox0.Font.IsBold = true;

            //Set the font size.
            textbox0.Font.Size = 14;

            //Set font attribute to italic.
            textbox0.Font.IsItalic = true;

            //Add a hyperlink to the textbox.
            textbox0.AddHyperlink("http://www.aspose.com/");

            //Get the filformat of the textbox.
            MsoFillFormat fillformat = textbox0.FillFormat;

            //Set the fillcolor.
            fillformat.ForeColor = Color.Silver;

            //Get the lineformat type of the textbox.
            MsoLineFormat lineformat = textbox0.LineFormat;

            //Set the line style.
            lineformat.Style = MsoLineStyle.ThinThick;

            //Set the line weight.
            lineformat.Weight = 6;

            //Set the dash style to squaredot.
            lineformat.DashStyle = MsoLineDashStyle.SquareDot;

            //Add another textbox.
            textboxIndex = worksheet.TextBoxes.Add(15, 4, 85, 120);

            //Get the second textbox.
            Aspose.Cells.Drawing.TextBox textbox1 = worksheet.TextBoxes[textboxIndex];

            //Input some text to it.
            textbox1.Text = "This is another simple text box";

            //Set the placement type as the textbox will move and
            //resize with cells.
            textbox1.Placement = PlacementType.MoveAndSize;

            //Save the excel file.
            workbook.Save(dataDir + "book1.xls");
        }