static void Main(string[] args) { //Instantiate a new workbook. //Open the existing excel file. Workbook workbook = new Workbook("Watermark_Test1.xls"); //Get the chart in the first worksheet. Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0]; //Add a WordArt watermark (shape) to the chart's plot area. Aspose.Cells.Drawing.Shape wordart = chart.Shapes.AddTextEffectInChart(MsoPresetTextEffect.TextEffect2, "CONFIDENTIAL", "Arial Black", 66, false, false, 1200, 500, 2000, 3000); //Get the shape's fill format. Aspose.Cells.Drawing.MsoFillFormat wordArtFormat = wordart.FillFormat; //Set the transparency. wordArtFormat.Transparency = 0.9; //Get the line format and make it invisible. Aspose.Cells.Drawing.MsoLineFormat lineFormat = wordart.LineFormat; lineFormat.IsVisible = false; //Save the excel file. workbook.Save("outWatermark_Test1.xls"); }
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"); }
public static void Run() { //Output directory string outputDir = RunExamples.Get_OutputDirectory(); // 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 FillFormat wordArtFormat = wordart.Fill; // Set the transparency wordArtFormat.Transparency = 0.9; // Make the line invisible LineFormat lineFormat = wordart.Line; // Save the file workbook.Save(outputDir + "outputAddWordArtWatermarkToWorksheet.xlsx"); Console.WriteLine("AddWordArtWatermarkToWorksheet executed successfully.\r\n"); }
public static void Run() { // ExStart:AddWordArtWatermarkToChart // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Open the existing excel file. Workbook workbook = new Workbook(dataDir + "sample.xlsx"); // Get the chart in the first worksheet. Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0]; // Add a WordArt watermark (shape) to the chart's plot area. Aspose.Cells.Drawing.Shape wordart = chart.Shapes.AddTextEffectInChart(MsoPresetTextEffect.TextEffect2, "CONFIDENTIAL", "Arial Black", 66, false, false, 1200, 500, 2000, 3000); // Get the shape's fill format. FillFormat wordArtFormat = wordart.Fill; // Set the transparency. wordArtFormat.Transparency = 0.9; // Get the line format. LineFormat lineFormat = wordart.Line; // Set Line format to invisible. lineFormat.Weight = 0.0; // Save the excel file. workbook.Save(dataDir + "output_out_.xlsx"); // ExEnd:AddWordArtWatermarkToChart }
public static void Run() { //Source directory string sourceDir = RunExamples.Get_SourceDirectory(); //Output directory string outputDir = RunExamples.Get_OutputDirectory(); // Open the existing excel file. Workbook workbook = new Workbook(sourceDir + "sampleAddWordArtWatermarkToChart.xlsx"); // Get the chart in the first worksheet. Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0]; // Add a WordArt watermark (shape) to the chart's plot area. Aspose.Cells.Drawing.Shape wordart = chart.Shapes.AddTextEffectInChart(MsoPresetTextEffect.TextEffect2, "CONFIDENTIAL", "Arial Black", 66, false, false, 1200, 500, 2000, 3000); // Get the shape's fill format. FillFormat wordArtFormat = wordart.Fill; // Set the transparency. wordArtFormat.Transparency = 0.9; // Get the line format. LineFormat lineFormat = wordart.Line; // Set Line format to invisible. lineFormat.Weight = 0.0; // Save the excel file. workbook.Save(outputDir + "outputAddWordArtWatermarkToChart.xlsx"); Console.WriteLine("AddWordArtWatermarkToChart executed successfully."); }
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 }
/// <summary> /// /// </summary> /// <param name="watermarkText"></param> /// <param name="watermarkColor"></param> /// <returns></returns> public Response AddTextWatermark(DocumentInfo[] workbooks, string watermarkText, string watermarkColor) { if (workbooks == null) { return(PasswordProtectedResponse); } if (workbooks.Length == 0 || workbooks.Length > MaximumUploadFiles) { return(MaximumFileLimitsResponse); } var fileName = Path.GetFileName(workbooks[0].FileName); var folderName = Path.GetDirectoryName(workbooks[0].FileName); var color = GetColor(watermarkColor); foreach (var docInfo in workbooks) { var workbook = docInfo.Workbook; foreach (var sheet in workbook.Worksheets) { //// Add Watermark Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1, watermarkText, "Arial Black", 60, true, true , 18, 8, 1, 1, 130, 800); wordart.Fill.FillType = FillType.Solid; wordart.Fill.SolidFill.Color = color; } } SetDefaultOptions(workbooks, ""); Opts.AppName = "WatermarkApp"; Opts.MethodName = "AddTextWatermark"; Opts.ZipFileName = workbooks.Length > 1 ? "Converted workbooks" : Path.GetFileNameWithoutExtension(workbooks[0].FileName); var saveOpt = GetSaveOptions("xlsx"); return(Process((inFilePath, outPath, zipOutFolder) => { var tasks = workbooks.Select(doc => Task.Factory.StartNew(() => SaveDocument(doc, outPath, zipOutFolder, saveOpt))).ToArray(); Task.WaitAll(tasks); })); }
/// <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); }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.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 FillFormat wordArtFormat = wordart.Fill; // Set the transparency wordArtFormat.Transparency = 0.9; // Make the line invisible LineFormat lineFormat = wordart.Line; dataDir = dataDir + "Watermark_Test.out.xls"; // Save the file workbook.Save(dataDir); // ExEnd:1 Console.WriteLine("\nProcess completed successfully.\nFile saved at " + dataDir); }
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); }
public static void Main(string[] args) { // 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 excelbook = new Workbook(); //Add a group box to the first worksheet. Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(1, 0, 1, 0, 300, 250); //Set the caption of the group box. box.Text = "Age Groups"; box.Placement = PlacementType.FreeFloating; //Make it 2-D box. box.Shadow = false; //Add a radio button. Aspose.Cells.Drawing.RadioButton radio1 = excelbook.Worksheets[0].Shapes.AddRadioButton(3, 0, 2, 0, 30, 110); //Set its text string. radio1.Text = "20-29"; //Set A1 cell as a linked cell for the radio button. radio1.LinkedCell = "A1"; //Make the radio button 3-D. radio1.Shadow = true; //Set the foreground color of the radio button. radio1.FillFormat.ForeColor = Color.LightGreen; //Set the line style of the radio button. radio1.LineFormat.Style = MsoLineStyle.ThickThin; //Set the weight of the radio button. radio1.LineFormat.Weight = 4; //Set the line color of the radio button. radio1.LineFormat.ForeColor = Color.Blue; //Set the dash style of the radio button. radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid; //Make the line format visible. radio1.LineFormat.IsVisible = true; //Make the fill format visible. radio1.FillFormat.IsVisible = true; //Add another radio button. Aspose.Cells.Drawing.RadioButton radio2 = excelbook.Worksheets[0].Shapes.AddRadioButton(6, 0, 2, 0, 30, 110); //Set its text string. radio2.Text = "30-39"; //Set A1 cell as a linked cell for the radio button. radio2.LinkedCell = "A1"; //Make the radio button 3-D. radio2.Shadow = true; //Set the foreground color of the radio button. radio2.FillFormat.ForeColor = Color.LightGreen; //Set the line style of the radio button. radio2.LineFormat.Style = MsoLineStyle.ThickThin; //Set the weight of the radio button. radio2.LineFormat.Weight = 4; //Set the line color of the radio button. radio2.LineFormat.ForeColor = Color.Blue; //Set the dash style of the radio button. radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid; //Make the line format visible. radio2.LineFormat.IsVisible = true; //Make the fill format visible. radio2.FillFormat.IsVisible = true; //Add another radio button. Aspose.Cells.Drawing.RadioButton radio3 = excelbook.Worksheets[0].Shapes.AddRadioButton(9, 0, 2, 0, 30, 110); //Set its text string. radio3.Text = "40-49"; //Set A1 cell as a linked cell for the radio button. radio3.LinkedCell = "A1"; //Make the radio button 3-D. radio3.Shadow = true; //Set the foreground color of the radio button. radio3.FillFormat.ForeColor = Color.LightGreen; //Set the line style of the radio button. radio3.LineFormat.Style = MsoLineStyle.ThickThin; //Set the weight of the radio button. radio3.LineFormat.Weight = 4; //Set the line color of the radio button. radio3.LineFormat.ForeColor = Color.Blue; //Set the dash style of the radio button. radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid; //Make the line format visible. radio3.LineFormat.IsVisible = true; //Make the fill format visible. radio3.FillFormat.IsVisible = true; //Get the shapes. Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[] { box, radio1, radio2, radio3 }; //Group the shapes. Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects); //Save the excel file. excelbook.Save(dataDir + "book1.xls"); }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.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 excelbook = new Workbook(); // Add a group box to the first worksheet. Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(1, 0, 1, 0, 300, 250); // Set the caption of the group box. box.Text = "Age Groups"; box.Placement = PlacementType.FreeFloating; // Make it 2-D box. box.Shadow = false; // Add a radio button. Aspose.Cells.Drawing.RadioButton radio1 = excelbook.Worksheets[0].Shapes.AddRadioButton(3, 0, 2, 0, 30, 110); // Set its text string. radio1.Text = "20-29"; // Set A1 cell as a linked cell for the radio button. radio1.LinkedCell = "A1"; // Make the radio button 3-D. radio1.Shadow = true; // Set the weight of the radio button. radio1.Line.Weight = 4; // Set the dash style of the radio button. radio1.Line.DashStyle = MsoLineDashStyle.Solid; // Add another radio button. Aspose.Cells.Drawing.RadioButton radio2 = excelbook.Worksheets[0].Shapes.AddRadioButton(6, 0, 2, 0, 30, 110); // Set its text string. radio2.Text = "30-39"; // Set A1 cell as a linked cell for the radio button. radio2.LinkedCell = "A1"; // Make the radio button 3-D. radio2.Shadow = true; // Set the weight of the radio button. radio2.Line.Weight = 4; // Set the dash style of the radio button. radio2.Line.DashStyle = MsoLineDashStyle.Solid; // Add another radio button. Aspose.Cells.Drawing.RadioButton radio3 = excelbook.Worksheets[0].Shapes.AddRadioButton(9, 0, 2, 0, 30, 110); // Set its text string. radio3.Text = "40-49"; // Set A1 cell as a linked cell for the radio button. radio3.LinkedCell = "A1"; // Make the radio button 3-D. radio3.Shadow = true; // Set the weight of the radio button. radio3.Line.Weight = 4; // Set the dash style of the radio button. radio3.Line.DashStyle = MsoLineDashStyle.Solid; // Get the shapes. Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[] { box, radio1, radio2, radio3 }; // Group the shapes. Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects); // Save the excel file. excelbook.Save(dataDir + "book1.out.xls"); // ExEnd:1 }
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 excelbook = new Workbook(); //Add a group box to the first worksheet. Aspose.Cells.Drawing.GroupBox box = excelbook.Worksheets[0].Shapes.AddGroupBox(1, 0, 1, 0, 300, 250); //Set the caption of the group box. box.Text = "Age Groups"; box.Placement = PlacementType.FreeFloating; //Make it 2-D box. box.Shadow = false; //Add a radio button. Aspose.Cells.Drawing.RadioButton radio1 = excelbook.Worksheets[0].Shapes.AddRadioButton(3, 0, 2, 0, 30, 110); //Set its text string. radio1.Text = "20-29"; //Set A1 cell as a linked cell for the radio button. radio1.LinkedCell = "A1"; //Make the radio button 3-D. radio1.Shadow = true; //Set the foreground color of the radio button. radio1.FillFormat.ForeColor = Color.LightGreen; //Set the line style of the radio button. radio1.LineFormat.Style = MsoLineStyle.ThickThin; //Set the weight of the radio button. radio1.LineFormat.Weight = 4; //Set the line color of the radio button. radio1.LineFormat.ForeColor = Color.Blue; //Set the dash style of the radio button. radio1.LineFormat.DashStyle = MsoLineDashStyle.Solid; //Make the line format visible. radio1.LineFormat.IsVisible = true; //Make the fill format visible. radio1.FillFormat.IsVisible = true; //Add another radio button. Aspose.Cells.Drawing.RadioButton radio2 = excelbook.Worksheets[0].Shapes.AddRadioButton(6, 0, 2, 0, 30, 110); //Set its text string. radio2.Text = "30-39"; //Set A1 cell as a linked cell for the radio button. radio2.LinkedCell = "A1"; //Make the radio button 3-D. radio2.Shadow = true; //Set the foreground color of the radio button. radio2.FillFormat.ForeColor = Color.LightGreen; //Set the line style of the radio button. radio2.LineFormat.Style = MsoLineStyle.ThickThin; //Set the weight of the radio button. radio2.LineFormat.Weight = 4; //Set the line color of the radio button. radio2.LineFormat.ForeColor = Color.Blue; //Set the dash style of the radio button. radio2.LineFormat.DashStyle = MsoLineDashStyle.Solid; //Make the line format visible. radio2.LineFormat.IsVisible = true; //Make the fill format visible. radio2.FillFormat.IsVisible = true; //Add another radio button. Aspose.Cells.Drawing.RadioButton radio3 = excelbook.Worksheets[0].Shapes.AddRadioButton(9, 0, 2, 0, 30, 110); //Set its text string. radio3.Text = "40-49"; //Set A1 cell as a linked cell for the radio button. radio3.LinkedCell = "A1"; //Make the radio button 3-D. radio3.Shadow = true; //Set the foreground color of the radio button. radio3.FillFormat.ForeColor = Color.LightGreen; //Set the line style of the radio button. radio3.LineFormat.Style = MsoLineStyle.ThickThin; //Set the weight of the radio button. radio3.LineFormat.Weight = 4; //Set the line color of the radio button. radio3.LineFormat.ForeColor = Color.Blue; //Set the dash style of the radio button. radio3.LineFormat.DashStyle = MsoLineDashStyle.Solid; //Make the line format visible. radio3.LineFormat.IsVisible = true; //Make the fill format visible. radio3.FillFormat.IsVisible = true; //Get the shapes. Aspose.Cells.Drawing.Shape[] shapeobjects = new Aspose.Cells.Drawing.Shape[] { box, radio1, radio2, radio3 }; //Group the shapes. Aspose.Cells.Drawing.GroupShape group = excelbook.Worksheets[0].Shapes.Group(shapeobjects); //Save the excel file. excelbook.Save(dataDir + "book1.xls"); }