We are using Aspose.Cells to create PNG snapshots of hundreds of Excel worksheets, for loading and displaying on end-users’ iPads. However the size of the PNG files being created is so large that we are running out of physical space. If, however, we take a PrintScreen of the same Worksheets, paste them into MSPaint, scale them to the same size (800 pixels wide) and save them from there, they are significantly smaller in size (about a quarter of the size).
Hi,
Thanks for your posting and using Aspose.Cells.
Please download and try the latest version: Aspose.Cells
for .NET v7.4.2.5 It works fine.
It generates 47kb png file. The one you provided was 100kb. Please try the following code. We have also attached the output file for your reference.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\test.xlsx”;
Workbook book = new Workbook(filePath);
Worksheet sheet = book.Worksheets[0];
int width = 800;
//Define ImageOrPrintOptions
Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;
//Set only one page would be rendered for the image
imgOptions.OnePagePerSheet = true;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
PageSetup ps = sheet.PageSetup;
ps.PrintArea = “A1:J31”;
//Create the SheetRender object based on the sheet with its
//ImageOrPrintOptions attributes
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);
//Render the sheet to a Bitmap
Bitmap bitmap = sr.ToImage(0);
//Convert the Bitmap to a BitmapSource
bitmap.Save(filePath + “.out.png”, ImageFormat.Png);
Thanks for that - it does indeed make a smaller file now.
Hi,
Thanks for your posting and using Aspose.Cells.
We are afraid, you cannot set image width and height in pixels using Aspose,Cells APIs. You will have to use .NET image manipulating tools for this purpose.
Okay - I understand.
Hi,
Thanks for your posting and using Aspose.Cells.
Arial font is a default font. If there is no font installed, Aspose.Cells will use Arial font. Probably, this is the reason, Arial gives better results. To get correct results, fonts must be installed on user machine. There is no special list of fonts that Aspose.Cells support.