Aspose.cells.rendering + image with fixed size

Hi syncfusion team,

i wrote the bottom message (in blue) to the apose.Words forum but i have also questions to the aspose.cells team.
Is there a possibility to set a imagesize to the aspose.cells.rendering.sheetrender object.
I need a custom sized image of the worksheet. i´ve tried some of the sheetrender\ImageOrPrintOptions settings but i got only images of the whole contained sheetdata.

look below for details of my problem…

I use. Aspose.Words. 14.8 and Aspose.Cells 8.2.1
Thank you!

Regards,
Christoph


i´m unsure if this message is right here (or for Aspose.cells).
I
use Microsoft Open XML SDK and Aspose.Cells to manipulate Word
documents, more precisely, manipulate embedded charts and spreadsheets.

For embedded spreadsheets i do following in my current application:
1. Get all embedded spreadsheets (the underlaying excel document) (for this i use OpenXML)
2. Add\manipulate data to\on this this excel-documents. (for this i use Aspose.cells)
3. Save the manipulated sheets back to the word\xml structure. (for this i use OpenXML).
Next is the point where i have problem:
4.
If you open a docx or docm with a embedded spreadsheet you see only a
image\screenshot of the spreadsheet on the word document. This image
must be replaced too with an actual image of the manipulated data of the
underlaying excel-sheet. Here´s my problem with openXML and
Aspose.Cells. Because the docx palceholder has a fixed size, i need a
screenshot\image of the worksheet with the same size. But if i use the
(only possibility ??) “Aspose.Cells.Rendering.SheetRender” i find no way
to set a image size before i call the ToImage() function. So i get a
image of all of the data in the worksheet. Because of this, the size of
the image could vary. if i place this image to the docx structure and
open this file in word the image is stretched or compressed because of
the different size settings. Alter the image size in the docx-xml
structure to the size of the new image is no possibility.

Is
there a possibility in Aspose.Words to save a manipulated Worksheet back
to the Word-Structure an automatically replace the corresponding image
with an actual one?.

I use. Aspose.Words. 14.8 and Aspose.Cells 8.2.1

Regards,
Christoph

Hi,

ReportWithAspose:
.....i have also questions to the aspose.cells team.
Is there a possibility to set a imagesize to the aspose.cells.rendering.sheetrender object.
I need a custom sized image of the worksheet. i´ve tried some of the sheetrender\ImageOrPrintOptions settings but i got only images of the whole contained sheetdata.

Well, I think you may try to take the image of your desired range in the sheet. You may set the printable area to your desired range of cells and then set all the margins to 0. Also set ImageOrPrintOptions.OnePagePerSheet to true on a safer side.

The following code takes an image of the range E8:H15 in the first worksheet, please refer to it and try to write your own codes accordingly for your needs:
e.g
Sample code:

string filePath = @"e:\test2\Book1.xlsx";

//Create workbook from source file.
Workbook workbook = new Workbook(filePath);

//Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];

//Set the print area with your desired range
worksheet.PageSetup.PrintArea = "E8:H15";

//Set all margins as 0
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;

//Set OnePagePerSheet option as true
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.OnePagePerSheet = true;
options.ImageFormat = ImageFormat.Jpeg;

//Take the image of your worksheet
SheetRender sr = new SheetRender(worksheet, options);
sr.ToImage(0, filePath + ".out.jpg");


Hope, this helps you a bit.

Thank you.

Hi,

thank you for the fast response.

Hmm, no it not really helps. Because i have a fixed image size, given by the image-“placeholder” for the embedded spreadsheet in the word document, i need an image with the same size from the current\altered Worksheet. => i can´t use the range option.

Regards,
Christoph

Hi,


I am afraid, Aspose.Cells is a spreadsheet management library and not an image processing library to crop, resize or compress images. It does have this advanced feature i.e., Sheet to Image, that you may make use of it to render image files from your desired worksheets. For your requirements, to resize or crop images, you may use our other component named Aspose.Imaging for .NET if it suits your needs:
http://www.aspose.com/.net/imaging-component.aspx

Thank you.

Hi,

thx for yout fast respone. Ok i´ve looked into this Asponse.Imagine component.
Now i have the problem to resize a “emf” File.
Because:
There is a emf file saved (in the docx structure of the Word file) as Image for the embedded spreadsheet. With Aspose.Cells->Sheedrenderer i can save\export a emf image of a sheet. Now i had to resize this emf file but when i use the Aspose.imaging.image component to open an emf image i will get a “Cannot open an image. The image file format may be not supported at the moment” exception.
Do you have a solution for my problem.

(i edit this post again: i don´t want to size\zoom the source image,
i only want to cut out height x width pixel of the source image to the
destination image, beginning at the upper left corner).

Thx,
Christoph

Hi,

ReportWithAspose:
....Now i had to resize this emf file but when i use the Aspose.imaging.image component to open an emf image i will get a "Cannot open an image. The image file format may be not supported at the moment" exception.
Do you have a solution for my problem.


Please post your query with all the details, sample code and attachments in Aspose.Imaging forum, one of my colleague from Aspose.Imaging team will help you soon there:
http://www.aspose.com/community/forums/aspose.imaging-product-family/498/showforum.aspx

Thank you.