Hello, we are trying to get images from excel tables. Bellow is the code we are using and I’ve uploaded the input & output data. The problem is that the generated picture contains a lot of white space!
I’ve applied the instructions to remove white space as you can see below but no luck.
Furthermore it works on other machines except for my own. I am the only one who upgraded to Windows 10 (1809) and on Windows 7 and deployment server this does not occur (I published my code base). I installed the latest version of Cells (19.11.0).
The question is: what difference in environment could be causing the white space? And what could we do to prevent this in the future when everything will be migrated?
private static void NewMethod(string printArea = null)
{
new Aspose.Cells.License().SetLicense(@"...");
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(@"... template.xlsx");
Aspose.Cells.Worksheet AsposeSheet = wb.Worksheets[0];
Aspose.Cells.PageSetup pageSetup = AsposeSheet.PageSetup;
pageSetup.PrintArea = new SheetNameWithPrintArea("kpi summary table", "A1:G6").PrintArea;
pageSetup.RightMargin = pageSetup.BottomMargin = pageSetup.LeftMargin = pageSetup.TopMargin = 0;
var stream = new System.IO.MemoryStream();
new Aspose.Cells.Rendering.SheetRender(AsposeSheet, IMAGE_OR_PRINT_OPTIONS).ToImage(0, stream);
var file = new System.IO.FileStream(@"... picture.emf", System.IO.FileMode.Create);
stream.Position = 0;
stream.CopyTo(file);
file.Position = 0;
file.Flush();
stream.Close();
file.Close();
}
public static Aspose.Cells.Rendering.ImageOrPrintOptions IMAGE_OR_PRINT_OPTIONS
{
get
{
return new Aspose.Cells.Rendering.ImageOrPrintOptions
{
SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,
EmfType = System.Drawing.Imaging.EmfType.EmfPlusDual,
ImageType = Aspose.Cells.Drawing.ImageType.Emf,
PrintingPage = Aspose.Cells.PrintingPageType.IgnoreBlank,
IsCellAutoFit = true,
OnePagePerSheet = true,
};
}
}