Can't convert to image

Hi,


I can not convert the attached file to image (either get an invalid parameter error or, crash). My code is as follows :


Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(@“C:\TEMP\test4\Sample - Superstore Sales (Excel).xls”);

Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
imgOptions.OnePagePerSheet = true;
Aspose.Cells.Worksheet sheet = wb.Worksheets[0];
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);

System.Drawing.Bitmap bitmap = sr.ToImage(0);
bitmap.Save(@“C:\TEMP\test4\sonuc.png”, System.Drawing.Imaging.ImageFormat.Png);

Thank you,

Hi,


Thanks for the template file and sample code.

Well, I have evaluated your scenario/ case a bit. I checked your first worksheet (in the workbook) which has 8400 records in it and when I take the print preview of the sheet in MS Excel manually, it shows me 972 pages in total. So, how could you render one page per this large sheet as you specify in your code as:
e.g
Sample code:
imgOptions.OnePagePerSheet = true; //this would cause the error

I am afraid, this is not possible i.e., render so much data into a single page of the image, so you cannot render that big sheet into a single page. You may confirm this even you cannot do this in Ms Excel either (set some options e.g put some numeric value for FitToPages Tall and Wide options etc. and take the print preview of the sheet). In short, please remove this line of code. Instead you should try to use some other options e.g
imgOptions.AllColumnsInOnePagePerSheet = true;
to render all the columns in the page, this way, you could at least render all the columns in a single page although you have to render multiple pages for data for sure.

Furthermore, you may try to use Fit to Pages Tall/Wide options of PageSetup accordingly before rendering to image files.

Thank you.

Thank you for quick response and the information suplied.


It seems that I need to render the worksheet partially. I need a way to get image of the rendered worksheet with a bounding box. The size and position of the box may be in milimeters (or pixels maybe). Another requirement is getting the full extend in same units (mm/pixel).
So I can put the images near to each other and show whole document (like map applications).

1. Do you have any suggestions about the method?
2. How can I get image of bbox and total size?

Thanks…

Hi,


Well, if you need to partially render your worksheet to generate images, you may first specify the PageSetup’s printable area and then render image(s) of the sheet accordingly.

And, I am not sure about your requirement related to bounding box. We follow MS Excel standards and specifications, so how could you do this in Ms Excel? Kindly provide us a template file with the bbox, you may create such a file in Ms Excel manually and provide us here with all the details, we will check how to do it via Aspose.Cells APIs.

Thank you.

Your comments helped me too much, thank you.

I’m trying to create a viewer and I’ll ask if I have any problem.

By the way, the cells in rendered image are little bit cropped, while I can’t see any problem on Excel. You may see the attached image. Top parts of letters are cropped.

Thank you.
Hi,

huseyincandan:
By the way, the cells in rendered image are little bit cropped, while I can't see any problem on Excel. You may see the attached image. Top parts of letters are cropped.


After an initial test, I observed the issue as you mentioned. I found some cell contents are cropped at the top a bit in the output image. I am specifying the printable area to render image for a portion in the sheet. I used the following sample code with your template file, the output image is attached here:
e.g
Sample code:

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(@"e:\test2\Sample+-+Superstore+Sales+(Excel).xls");

Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
Aspose.Cells.Worksheet sheet = wb.Worksheets[0];

sheet.PageSetup.PrintArea = "K1625:O1651";

Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);

System.Drawing.Bitmap bitmap = sr.ToImage(0);
bitmap.Save(@"e:\test2\out1Sample1_new1.png", System.Drawing.Imaging.ImageFormat.Png);

I have logged a ticket with an id "CELLSNET-43769" for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,


Could you please share the font (“MS Sans Serif”) used in your template Excel file and also provide the PDF generated by Aspose.Cells for .NET v8.5.0.3 on your env. It will help us to evaluate your issue precisely in figuring out your issue soon.

Thank you.

Hi,


I’ve attached the font, but we did not create the file I’ve sent. We have downloaded it from internet. I’m not sure but url may be http://community.tableau.com/docs/DOC-1236.
We are using Aspose.Cells for .NET v8.4.0.0 and did not downloaded/installed v8.5 yet. So I can not send PDF for now.

Thank you.

Hi,


Thanks for providing us the font file.

I have attached the zipped archive to your logged issue “CELLSNET-43769” into our database. We also demand the PDF file which should be generated with our latest version/fix v8.5.0.3 in your environment using your original template file (with font(s)), please do it (if possible) soon. Anyways, our product will try to evaluate your issue based on your provided font file.

Once we have any update on it, we will let you know here.

Thank you.


Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.5.1.1 and let us know your feedback.

We only support TTF and TTC font files.The fon font is not supported. So the set “MS Sans Serif” font will be replaced.

We have improved the output image.But it is possible that the replaced font height is so big that the text will be cut.

The issues you have found earlier (filed as CELLSNET-43769) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.