I am testing the latest version of Aspose Cells to try to solve a problem we are seeing with an earlier version (where rendered worksheets don’t have the charts established before they are rendered, resulting in blank charts on the image).
Hi Nigel,
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
Please use the following code, it generates the image fine. I have also attached the output image for your reference.
Please download and use the latest version:
Aspose.Cells
for .NET v7.3.0.2
C#
//Instantiating a Workbook object
Workbook workbook = new Workbook(filePath);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
worksheet.PageSetup.PrintArea = “A1:H31”;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.OnePagePerSheet = true;
SheetRender sr = new SheetRender(worksheet, opts);
Bitmap bmp = sr.ToImage(0);
Thanks for the prompt replies.
Hi,
Thanks for your feedback.
It’s strange that this issue is occurring on your machine and not ours. Please let us know your System Environment.
Are you using .NET Framework Client Profile? Because there is a separate Aspose.Cells dll which can work with .NET Framework Client Profile.
Also, please make sure, there is not any other Aspose.Cells dll in your GAC (Global Assembly Cache) and you have updated the reference to latest dll and using it.
Thanks Shakeel,
Hi,
Hi Amjad,
Hi Nigel,
Hi Amjad,
Hi,
VS.NET
2008, now updated the filePath variable’s value accordingly. Added reference to v7.3.0.2 and run the project, it works absolutely fine, you may check the output image in the archive. I have zipped your updated project and attach the archive here for your reference.VS.NET
, update the filePath variable’s value and just run it, it should work fine to produce the image same as mine.Hi Amjad,
Hi,ndsykes:Hi Amjad,I'm afraid that the result remains the same for me - i.e. cropped weirdly.All I did was open the project you sent, change the path to point to the Test.xls on my PC and ran it.What could possibly be causing this to be different between our PCs?Nigel
I have checked your projects and I found no problem. All seems ok to me.
Could you please download the client profile dll from the major release: Aspose.Cells for .NET 7.3.0
Once, you will extract the msi file, you will find 3 directories inside Bin directory namely
- net1.1
- net2.0
- net3.5_ClientProfile (try this one)
Update your project i.e ExcelToJpeg2.zip dll reference to one as present inside the net3.5_ClientProfile folder and check the output.
Let us know your feedback.
Hi Shakeel,
Hi guys,
Hi,
In order to diagnose this issue further, could you please try the following code on number of other xls/xlsx files and share your results?
Please post all your source files and their output images. It will help us see if the problem is related to single file or it occurs with all files.
Please also download and use the latest version:
Aspose.Cells
for .NET v7.3.0.3
C#
//Try number of xls/xlsx files by changing this path
string filePath = @“F:\shapes.xls”;
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.Worksheets[0];
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.OnePagePerSheet = true;
opts.ImageFormat = ImageFormat.Jpeg;
SheetRender render = new SheetRender(worksheet, opts);
render.ToImage(0, filePath + “.out.jpg”);
Hi Shakeel,
Hi Shakeel,
Hi,
Aspose.Cells for .NET does not depend upon MS-Excel at all. It generates images of your workbook without the need of MS-Excel.
The cropping issue did exist in the older versions but it does not exist in the latest version, so it is difficult to tell what sort of problem and why you are facing it.
All I can think is that you are accidentally using some older version.
In order to check it, could you please run this code, if the following code is runnable at your end, then it means you are surely using the latest version because these two new properties have been introduced just recently and does not exist in older versions.
Please download and use the latest fix:
Aspose.Cells
for .NET v7.3.0.3
Now the link is correct. Thanks.
C#
HtmlSaveOptions opts = new HtmlSaveOptions();
opts.HiddenRowDisplayType = HtmlHiddenRowDisplayType.Remove;
opts.HiddenColDisplayType = HtmlHiddenColDisplayType.Remove;
Debug.WriteLine(opts.HiddenColDisplayType);
Debug.WriteLine(opts.HiddenRowDisplayType);
Hi Shakeel,