Cell Height (GetWidthOfValue Height Equivalent)

Is there a way to get the height of the value in pixels for a cell like the GetWidthOfValue does for width?

Hi,

Thanks for your posting and using Aspose.Cells.

As a workaround, you can get the Cells.GetRowHeightPixel() method for your needs. It will return the height of your row in pixels.

That doesn’t really work for my scenario. If the value in the cell is being cut off because of the row height, I want to know. I’m able to tell for the width using GetWidthOfValue, but I can’t figure out a way to also do it for the height.

Hi,

Thanks for your posting and using Aspose.Cells.

It seems to be a new feature. Please provide us your detailed description of your requirements with some sample excel file, code and screenshots which you think might be helpful for us.

It will help us look into you requirements more closely and precisely and we will implement in our next versions.

Thanks for your cooperation.

In the example document, I want to be able to tell that cell A1 has a value which is cutoff.

cheatwole:
That doesn't really work for my scenario. If the value in the cell is being cut off because of the row height, I want to know. I'm able to tell for the width using GetWidthOfValue, but I can't figure out a way to also do it for the height.
Hi,

Thanks for your sample file and using Aspose.Cells.

Please also let us know how are you able to know the value of cell is cut off width wise using the GetWidthOfValue so that we could implment the equivalent function GetHeightOfValue.

It will be helpful if you could provide us a sample code utilizing the GetWidthOfValue method.

Workbook workbook = new Workbook(@"C:\Example.xlsx");
workbook.Save(@"C:\ExampleWithout.pdf", SaveFormat.Pdf);
foreach (var worksheet in workbook.Worksheets)
{
foreach (Cell cell in worksheet.Cells)
{
int cellWidth = cell.GetWidthOfValue();
var columnWidth = worksheet.Cells.GetColumnWidthPixel(cell.Column);
if (columnWidth < cellWidth)
{
worksheet.Cells.SetColumnWidthPixel(cell.Column, cellWidth);
}
}
}
workbook.Save(@"C:\ExampleWith.pdf", SaveFormat.Pdf);

Hi,

Thanks for your example and using Aspose.Cells.

Please use AutoFitRows method to autofit rows automatically and AutoFitColumns method to autofit the columns automatically.

This should fit your needs. Let us know if these methods don’t solve your problem in hand.

Please see the following sample code and the output pdf generated by it for your reference.

C#


Workbook workbook = new Workbook(@“Example.xlsx”);


Worksheet ws = workbook.Worksheets[0];

ws.AutoFitRows();


workbook.Save(“output.pdf”);

AutoFitRows and AutoFitColumns do not fit my needs. In my attached document, I want the row with the black background to remain as is, but with AutoFitRows, it will be expanded.


Workbook workbook = new Workbook(@“C:\Example.xlsx”);
workbook.Save(@“C:\ExampleWithout.pdf”, SaveFormat.Pdf);
foreach (var worksheet in workbook.Worksheets)
{
worksheet.AutoFitRows();
}
workbook.Save(@“C:\ExampleWith.pdf”, SaveFormat.Pdf);

Hi,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue. So we have logged a New Feature request in our database to support this feature. We will look into it and implement it if possible. Once it is implemented or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43777 - Cell.GetHeightOfValue() similar to Cell.GetWidthOfValue() needed

Hi,

Thanks for using Aspose.Cells.

We have fixed
this issue now. We will provide you a fix in couple of days after
incorporating other enhancements and fixes and conducting some extensive
testing. Once, it is available for you, we will let you know asap by
posting in this thread.

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


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

Thanks! It appears to work correctly.

Hi,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the latest version. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan