We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Generate thumbnail with file xls and xlsx

Hello i need your help,

i want created thumbnail for file xls and xslx.

i have already possibilities create thumbnail for doc docx pdf and now i need thumbnail for xls xlsx and ppt pptx but i don't find good methode for this.

Can you help me ?

Hi Romain,

Please try the following code snippet to generate the Thumbnail. I hope this will work for you. If still there is any issue, please fell free to contact us.

Code snippet:
internal void GetTumbnailFromWorkbook(string excelFile, string thumbnailFile, int widthPx, i
nt heightPx)
Workbook book = new Workbook(excelFile);
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
imgOptions.VerticalResolution = 200;
imgOptions.HorizontalResolution = 200;
imgOptions.OnePagePerSheet = true;
Worksheet sheet = book.Worksheets[0];
SheetRender sr = new SheetRender(sheet, imgOptions);
Bitmap bmp = sr.ToImage(0);
Bitmap thumb = new Bitmap(widthPx, heightPx);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(thumb);
gr.DrawImage(bmp, 0, 0, widthPx, widthPx);
"c:\\thumb.bmp", 100, 100);