Hi, this is the other question following by my previous post.
We would like to generate an image from one sheet and insert it to other sheet with good performance.
Currently, we saved an image to local drive and insert back to the worksheet.
Code example below.
static void Main(string[] args)
{
// new Workbook(_sourceFile.FullName);
var _workbook = new Workbook(“Source\SourceFile.xlsx”);
Worksheet sheet = _workbook.Worksheets["Disclosure"];
Aspose.Cells.Rendering.ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 400;
options.VerticalResolution = 400;
options.ImageType = Aspose.Cells.Drawing.ImageType.Jpeg;
options.IsImageFitToPage = true;
options.IsCellAutoFit = true;
options.PrintingPage = PrintingPageType.IgnoreBlank;
options.OnePagePerSheet = true;
var targetFile = "outputConvertWorksheetToImageByPage.Jpeg";
SheetRender sr = new SheetRender(sheet, options);
for (int j = 0; j < sr.PageCount; j++)
{
sr.ToImage(j, targetFile);
}
_workbook.Worksheets["Target"].Pictures.Add(0, 0, "outputConvertWorksheetToImageByPage.Jpeg");
_workbook.Save("TargetFile.xlsx");
}
Is there any way ImageOrPrintOptions() and generate an image stream rather than physical image? Hence we can add image stream to new sheet?
something like that…
int indexPicture = worksheet.Pictures.Add(0, 0, stream);