Hi team,
We are using Aspose cell to generate image(snapshot) of excel sheet.
below is code which generates image of an excel sheet provide (by default first sheet’s snapshot is taken)
public MemoryStream ExtractActiveCellAsImage(byte[] inputExcelData, int activeWorkSheet)
{
MemoryStream inputStream = new MemoryStream(inputExcelData);
inputStream.Position = 0;
Workbook book = new Workbook(inputStream);
Aspose.Cells.Worksheet sheet = book.Worksheets[0];
//Set left, top, right, bottom margins to 0
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.TopMargin = 0;
sheet.PageSetup.BottomMargin = 0;
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = ImageFormat.Png;
imgOptions.OnePagePerSheet = true;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
MemoryStream imageStream = new MemoryStream();
imageStream.Position = 0;
SheetRender sr = new SheetRender(sheet, imgOptions);
sr.ToImage(activeWorkSheet, imageStream);
return imageStream;
}
But the grid lines of excel sheets are not displayed in snap shot.
See attached sample for the details.
Image.png is generated image by above code
And the file expected.docx contains desire image output. (i.e excel sheet image Generated by MS word)
Please help us in this issue.
Thanks and regards,
Nakul