Infoga bakgrundsbild i Excel

Ange bakgrund på kalkylblad i Microsoft Excel

För att ange ett kalkylblads bakgrundsbild i Microsoft Excel (t.ex. Microsoft Excel 2019):

  1. Från menyn Sidlayout, hitta alternativet Sidlayout och klicka sedan på alternativet Bakgrund.
  2. Välj en bild för att sätta kalkylbladets bakgrundsbild.

Ange bakgrundsbild med Aspose.Cells

Koden nedan ställer in en bakgrundsbild med en bild från en ström.

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook
# Create a new Workbook.
workbook = Workbook()
# Get the first worksheet.
worksheet = workbook.getWorksheets().get(0)
# Get the background picture.
with open('Background.jpg', 'rb') as f:
data = f.read()
# Set the background image for the sheet.
worksheet.setBackgroundImage(data)
# Save the excel file
workbook.save("output.xlsx")
jpype.shutdownJVM()