// SPDX-License-Identifier: MIT OR Apache-2.0
//
// Copyright 2022-2026, John McNamara, jmcnamara@cpan.org
//! This example shows how to create an image object and use it to insert the
//! image into a worksheet. The image in this case is scaled.
use rust_xlsxwriter::{Image, Workbook, XlsxError};
fn main() -> Result<(), XlsxError> {
// Create a new Excel file object.
let mut workbook = Workbook::new();
// Add a worksheet to the workbook.
let worksheet = workbook.add_worksheet();
// Create a new image object and set the image scale.
let image = Image::new("examples/rust_logo.png")?
.set_scale_height(0.75)
.set_scale_width(0.75);
// Insert the image.
worksheet.insert_image(1, 2, &image)?;
// Save the file to disk.
workbook.save("image.xlsx")?;
Ok(())
}