PicFormatOption.Type
PicFormatOption.Type property
Gets or sets the picture fill type.
public FillPictureType Type { get; set; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Drawing;
using System;
using System.IO;
public class PicFormatOptionPropertyTypeDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Create a simple 1x1 pixel BMP image
byte[] bmpBytes = new byte[]
{
0x42, 0x4D, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
};
// Add picture to worksheet
int pictureIndex = worksheet.Pictures.Add(0, 0, new MemoryStream(bmpBytes));
Picture picture = worksheet.Pictures[pictureIndex];
// Set picture position and size
picture.UpperLeftRow = 0;
picture.UpperLeftColumn = 0;
picture.LowerRightRow = 5;
picture.LowerRightColumn = 5;
try
{
// Get the PicFormatOption from the picture's texture fill
PicFormatOption picFormat = picture.Fill.TextureFill.PicFormatOption;
// Display the current Type value
Console.WriteLine("Current Type: " + picFormat.Type);
// Set different Type values and display them
picFormat.Type = FillPictureType.Stretch;
Console.WriteLine("Type set to Stretch: " + picFormat.Type);
picFormat.Type = FillPictureType.Stack;
Console.WriteLine("Type set to Stack: " + picFormat.Type);
picFormat.Type = FillPictureType.StackAndScale;
Console.WriteLine("Type set to StackAndScale: " + picFormat.Type);
// Save the workbook
workbook.Save("PicFormatOptionTypeDemo.xlsx");
Console.WriteLine("Type property demonstration completed successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
See Also
- enum FillPictureType
- class PicFormatOption
- namespace Aspose.Cells.Drawing
- assembly Aspose.Cells