Free Support Forum - aspose.com

SheetRender Problem

I am currently evaluating your product. I have a project where I am trying to render spreadsheets to a PNG file. I am attaching a sample spreadsheet (TestSpreadsheet.xlsx), a file showing what the output should look like (TestSpreadsheet.png), and the output from the SheetRender method (SheetRender.png).

Since I am new to your product, there may be a better way to render the sheet, but here is the code I am using:

Dim book As New Workbook("TestSpreadsheet.xlsx")
Dim sheet As Worksheet = book.Worksheets("COMPLEX REC")

sheet.PageSetup.Orientation = PageOrientationType.Landscape
sheet.PageSetup.PaperSize = PaperSizeType.PaperLetterRotated
sheet.PageSetup.FitToPagesTall = 1
sheet.PageSetup.FitToPagesWide = 1

Dim imgOptions As New ImageOrPrintOptions()
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
imgOptions.HorizontalResolution = 300
imgOptions.VerticalResolution = 300
imgOptions.IsImageFitToPage = True

Dim sr As New SheetRender(sheet, imgOptions)
Dim bitmap As Bitmap = sr.ToImage(0)
bitmap.Save("TestPNG.png", System.Drawing.Imaging.ImageFormat.Png)

The output from this snippet is an incomplete image (it is cut off on the right and the bottom). I have changed various PageSetup values and various ImageOrPrintOptions, but the attached sample is the best I have been able to accomplish. Is there a better way to render the spreadsheet to an image that contains the entire Print Area?

Note also that the text appears to be scaled improperly -- note the "B Metric Formula" block and the red notes on the center chart.

Thanks,

Larry Grantham

Hi,

Please use the latest version:
Aspose.Cells for .NET v7.0.2

I found, it is working fine. Please see the output image and the code below.

VB.NET


Dim filePath As String = “F:\Shak-Data-RW\Downloads\TestSpreadsheet.xlsx”


Dim book As New Workbook(filePath)

Dim sheet As Worksheet = book.Worksheets(“COMPLEX REC”)


sheet.PageSetup.Orientation = PageOrientationType.Landscape

sheet.PageSetup.PaperSize = PaperSizeType.PaperLetterRotated

sheet.PageSetup.FitToPagesTall = 1

sheet.PageSetup.FitToPagesWide = 1


Dim imgOptions As New ImageOrPrintOptions()

imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png

imgOptions.HorizontalResolution = 300

imgOptions.VerticalResolution = 300

imgOptions.IsImageFitToPage = True


Dim sr As New SheetRender(sheet, imgOptions)

Dim bitmap As Bitmap = sr.ToImage(0)

bitmap.Save(filePath + “_TestPNG.png”, System.Drawing.Imaging.ImageFormat.Png)

Shakeel,

Thank you for the response. I see that your output looks correct. However, I still cannot duplicate your results. The code you have posted is exactly what I use (except for "filePath"). I am using Aspose.Cells for .NET v7.0.2. Perhaps there is some environment difference? My PC is running Windows 7 Professional 64-bit. I am developing in Visual Studio 2010. I have tried various .NET Framework targets such as 2.0, 3.0, 3.5, 3.5 Client Profile, 4, and 4 Client Profile, but all produce the same cutoff result.

Any ideas you have would be appreciated?

Thanks,

Larry

Hi,

Please try this latest version:
Aspose.Cells for .NET v7.0.2.1


and let me know your feedback. If you are still having problem, then please let me know your complete System Environment including .NET framework.


Still no change in output. I have attached a console application solution that contains everything to duplicate the problem on my PC. Perhaps I am simply doing something wrong.

My current system environment is:

Microsoft Visual Studio 2010 Ultimate with SP1
Version 4.0.30319 SP1

From System Information in Visual Studio
==========================================
OS Name Microsoft Windows 7 Professional
Version 6.1.7600 Build 7600
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Manufacturer Dell Inc.
System Model OptiPlex 380
System Type x64-based PC
Processor Pentium(R) Dual-Core CPU E5400 @ 2.70GHz, 2700 Mhz, 2 Core(s), 2 Logical Processor(s)
BIOS Version/Date Dell Inc. A04, 12/20/2010
SMBIOS Version 2.5
Windows Directory C:\Windows
System Directory C:\Windows\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "6.1.7600.16385"
Time Zone Eastern Daylight Time
Installed Physical Memory (RAM) 8.00 GB
Total Physical Memory 7.93 GB
Available Physical Memory 5.13 GB
Total Virtual Memory 15.9 GB
Available Virtual Memory 12.8 GB
Page File Space 7.93 GB
Page File C:\pagefile.sys

Please let me know if there is anything else that would be helpful.

Thanks...

Hi,

Will you please also mention the .NET Framework installed on your computer, if you have multiple frameworks, you can mention all.

Let me know, if you have .NET Framework Client Profile installed or not.

Shakeel,

I have all versions of the .NET Framework -- 2.0, 3.0, 3.5, 3.5 Client Profile, 4, and 4 Client Profile. I generally develop for .Net Framework 4.

However, I believe I have found the problem. I generally run my monitor at a high resolution with text sized at 125% (see attachment). In Windows 7, if I set this back to 100%, the output is produced correctly. At 125% it is incorrect.

Thanks,

Larry

Hi,

It’s great, you found the solution. However, it is strange, resolution is causing a problem. I have added your comment in our database so that development team could look into it.