Excel text box is resized incorrectly when rendering to image

Hello! When rendering an Excel range containing a text box sized to display only 3 digits, the text box in the output image has a bigger width to show all the digits in the text box. Please, check the attached console project!

Thank you.

Hi,

I can notice the issue as you mentioned by using your sample code with the template file. The text box is shown more wider to show its contents inside it in the generated image file.

Sample code:

var workbook = new Workbook(@"E:\test2\TextBoxInExcel\TextBoxInExcel\TextBoxResize.xlsx");

var imageOptions = new ImageOrPrintOptions
{
Quality = 100,
VerticalResolution = 200,
HorizontalResolution = 200,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true
};

var worksheet = workbook.Worksheets[0];

worksheet.PageSetup.PrintArea = string.Format("a1:e6");
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.BottomMargin = 0;

var sheetRender = new SheetRender(worksheet, imageOptions);

sheetRender.ToImage(0, @"E:\test2\TextBoxInExcel\TextBoxInExcel\output2.png");

I have logged a ticket with an id: CELLSNET-40902. We will look into it soon.

Thank you.

Hi,

We have fixed this issue.

Please download and try this fix: Aspose.Cells for .NET (Latest Version) and let us know your feedback.

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


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

Hi! I tried with Aspose Cells 7.3.2. This issue is present.

Thank you,

Dragos Culea

Hi,

Thanks for your feedback.

We have reopened this issue. We will fix the issue and update you asap.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\TextBoxResize.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.Worksheets[0];


ImageOrPrintOptions opts = new ImageOrPrintOptions();

opts.OnePagePerSheet = true;


SheetRender sr = new SheetRender(worksheet, opts);

Bitmap bmp = sr.ToImage(0);


bmp.Save(filePath + “.out.jpg”, ImageFormat.Jpeg);

Output Image & Screenshot:

Hi,


After looking into your issue further, we are afraid, we do not have better way to cope with it. The issue (visibility of text/data of Text box in MS Excel is not same as per the rendered PDF page) is due to the measurement of character string inaccurate, the issue is regarding Graphic.measureString(); this API of GDI+ has an issue which results in your issue. You may adjust your text box to show all the chars in the MS Excel’s sheet.

Anyways, we may look into it further after some time. If we have any update or solution or other way around, we will let you know here.

Sorry for any innocence caused!


Hello,

As per your statement: “we may look into it further after some time”, do you have any updates on this quite old issue ?

We’ve tested again with Aspose.Cells version 8.0.2.0, the behavior is the same.

Thank you in advance,
Mihai Andrei
Senior Software Engineer
IBM Romania

Hi,


I am afraid, the issue is still not resolved as I tested with v8.1.0.2. I have logged your concerns against your issue id “CELLSNET-40902” into our database.

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

Sorry for any inconvenience caused!

Hi,

Thanks for your using Aspose.Cells.

We have fixed this issue.

  • CELLSNET-40902 - Excel text box is resized incorrectly when rendering to image

Please download and try the latest fix: Aspose.Cells for .NET (Latest Version) and let us know your feedback.