Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Jun 25, 2024 7:54 pm

Hi all,

I was wondering if it was possible to display a watermark only on the first header of the worksheet? I'm currently using the code that was shown in the documentation but it displays on all pages. I only want it to display on the first.

Code: Select all
Font font = new Font("Arial", 60);

string watermark = "N/A";
 
Image imgWtrmrk = DrawWatermarkImage(watermark, font, Color.LightCoral, Color.White, worksheet.PageSetup.PageHeight, worksheet.PageSetup.PageWidth);

worksheet.PageSetup.LeftHeaderImage = imgWtrmrk;
worksheet.PageSetup.LeftHeader = "&G";

I've also tried to use FirstLeftHeaderImage, but I could not find any information regarding it.
Code: Select all
worksheet.PageSetup.FirstLeftHeaderImage = imgWtrmrk;


Thanks!

Dorian

- Spire.XLS Pro Edition Version 14.5.3
- .NET 7 MVC Web Application

dorianOrozco
 
Posts: 1
Joined: Tue Jun 25, 2024 7:40 pm

Wed Jun 26, 2024 5:45 am

Hello,

Thanks for your inquiry.
Please refer to the following code to implement your requirements. If you have any other questions, please feel free to write to us at any time.
Code: Select all
 Workbook workbook = new Workbook();
 workbook.LoadFromFile(@"Input.xlsx");
 System.Drawing.Image bufferedImage = System.Drawing.Image.FromFile("E-iceblueLogo.png");
 //Set image on first page header
 workbook.Worksheets[0].PageSetup.DifferentFirst = (byte)1;
 workbook.Worksheets[0].PageSetup.FirstLeftHeaderImage = bufferedImage;
 //Save the file
 workbook.SaveToFile("Output.xlsx", ExcelVersion.Version2010);

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.XLS