This project is read-only.
To apply a background image to a spreadsheet:
  1. Create a workbook and access the sheet you want to apply a background image to.
  2. Apply the background image.
  3. Save the workbook.

The code samples that follow show how to do this first with VSTO, using either C# or Visual Basic, and then with Aspose.Cells for .NET, again using either C# or Visual Basic.

The code examples in this article create a worksheet with a repeating background image, like the one in the screentshot below.

A background has been set for the worksheet.


//Instantiate the Application object.
            Excel.Application ExcelApp = Application;
            //Add a Workbook.
            Excel.Workbook objBook = ExcelApp.Workbooks.Add(System.Reflection.Missing.Value);
            //Get the First sheet.
            Excel.Worksheet objSheet = (Excel.Worksheet)objBook.Sheets["Sheet1"];

            //Set a background picture for the sheet.

            //Save the excel file.
            //Quit the Application.


//Instantiate a new Workbook.
            Workbook workbook = new Workbook();
            //Get the first worksheet. 
            Worksheet sheet = workbook.Worksheets[0];

            //Define a string variable to store the image path.
            string ImageUrl = "pic.jpeg";
            //Get the picture into the streams.
            FileStream fs = File.OpenRead(ImageUrl);
            //Define a byte array.
            byte[] imageData = new Byte[fs.Length];
            //Obtain the picture into the array of bytes from streams.
            fs.Read(imageData, 0, imageData.Length);
            //Close the stream.

            //Set the background image for the sheet.

            //Save the excel file.


*Sample Code

Last edited Jan 1, 2014 at 7:20 AM by asposemarketplace, version 3