Free Support Forum - aspose.com

Watermarks on Excel not visible when it has page breaks

Hi Team,


We are using Aspose.cells dll in our application to apply watermark to the Excel files. Currently we are facing an issue while the watermarking is being applied. The watermark that is applied using Aspose, is not visible when the Excel sheet has page breaks. I have attached the files with page break and without page break and their respective outputs when watermark is applied. I have also attached the console application, so that if any code change is required you can suggest me on this.

Can you please let us know the possible reason for this issue? Is there any solution for this?

Thanks,
Shreyas

Hi,


Thanks for the sample project with template files and details.

I have evaluated your scenario/ case a bit using your template files and sample code. Well, this is MS Excel’s behavior and nothing to do with Aspose.Cells APIs. MS Excel does not show watermarks when viewing the worksheets in Page Break preview, you got to open the sheet in Normal View in MS Excel. For confirmation, you may simply open the file “Withoutpagebreakoutput.xlsx” into MS Excel and click menu option View|Page Break Preview, you will see that the watermarks are not displayed anymore.

Let us know if we understand you correctly or you still have any confusion or issue.

Thank you.

Team,


Thank for the response. As you told, I could see that the image which we are setting as a background is not visible in the page break view and is visible only in Normal View.

Do we have any other way to implement the Watermark feature on the Excel, so that it looks the same way the background image does? Is there any other option available in Aspose to apply the Text in the background, so that it will be shown as Watermark?

Please let me know the alternatives if any.

Thanks,
Shreyas

Hi,


Well, you may try to use WordArt shape to add text watermark to the worksheet, see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/Add+WordArt+Watermark+to+Worksheet

Hope, this helps a bit.

Thank you.

Amjad,


Thank you for the reply.

I tried the way you suggested, by referring the link that was provided. I could achieve the feature of watermark on Excel using Wordart, but I could see an issue there.

- The wordart was shown above the Content of the Excel and hence the cell content in the Excel was hidden.

Is there any way to show the Wordart behind the content of the Excel like we do with background image, so that the cell data is not hidden?

Thanks,
Shreyas

Hi,


Well, this is MS Excel’s behavior for Word Art shape which take the priority when you click on its text. The contents in the cells are not hidden (or behind it) but you might not select the cell directly when you click on it as it would select the WordArt shape instead, you got to use arrow keys instead to select any cell, this is MS Excel’s behavior and nothing to do with Aspose.Cells APIs. I think you may try to lock certain aspects of word art shape, see the sample code below (especially the lines in bold) for your reference:
e.g
Sample code:

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

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

sheet.Cells[“B20”].PutValue(“Hello World!”);

//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 color
wordArtFormat.SetOneColorGradient(Color.Red, 0.2, GradientStyleType.Horizontal, 2);

//Set the transparency
wordArtFormat.Transparency = .9;

//Make the line invisible
LineFormat lineFormat = wordart.Line;
lineFormat.Weight = 0.0;

//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);

//Save the file
workbook.Save(“e:\test2\out1.xls”);

Hope, this helps a bit.

Thank you.

Amjad,


Currently we are using background image to apply Watermark for Excel and in our application, we have the option of Watermark percentage using which we can increase or decrease the brightness of Watermark.
I tried implementing the code you suggested and I could see the Wordart appearing as the watermark. But when I decreased the Transparency, the text behind was almost hidden. Is there any other way to achieve the modification of brightness of the Wordart, so that we can implement it in our application?

I have attached two screenshots. One containing background Image as the Watermark and the Other one has the Wordart. We could not see the content behind if the Transparency is decreased in case of Wordart where as the text will be clearly visible if we use background image. We need to achieve the look that background image was giving along with the option to increase and decrease the brightness without causing the problem for the user while trying to read the content of the Excel. In the other way, we should show the wordart as the background instead of showing it in the foreground of the cell content.

Is there any way to achieve this? if so, can you please share the sample code?

Thanks,
Shreyas





Hi,


Thanks for your posting and using Aspose.Cells.

You can also add watermark using the Header & Footer feature of Microsoft Excel.

Please check this article.

https://support.office.com/en-us/article/Mimic-a-watermark-in-Excel-5881607e-d76a-43a0-9ff5-6d63653f12bf

I have also attached the sample excel file which mimics watermark for your reference.

Hi Shakeel,


Thank you for providing the alternative solution to apply watermark.

But we have different issue there. If we apply watermark using Header and Footer feature, we can see the watermark in PageLayout and Print Preview. If the view is changed to Normal view, the Watermark disappears.

I have tried all the ways that have been suggested in this thread chain, but nothing is fulfilling our requirements. Initially we were asked to Use Wordart but if we use that, the Watremark comes before the text and we cannot put that Watermark as a background and also the brightness of the Watermark cannot be modified.

The other way as you said in the your mail, also has some limitations which I stated above.

Is there any way to achieve the Watermark feature which looks similar to the background Image, which should not disappear in any of the Views like Normal View, Page Layout View and Page break preview?

Thanks,
Shreyas

Hi,


Thanks for your posting and using Aspose.Cells.

I have tried it with Microsoft Excel to fulfill all of your requirements and found it is not possible.

For Normal View, you will have to use Sheet Background Image.
For Page Layout View, you will have to use Header & Footer Image.
For Page Break Preview, there is no solution.

Please check the sample excel file created by me via Microsoft Excel 2013.

If something is not possible with Microsoft Excel, it will also not be possible via Aspose.Cells. If you think, it is possible with Microsoft Excel, then create your expected excel file manually via Microsoft Excel and provide it to us. We will then look into it and provide you a solution. In case, the feature is missing in Aspose.Cells, we will add a New Feature request to support it in our future versions.

Thanks for your cooperation in this regard. Have a good day.