Hi! GetColumnWidthInch returns a different value than the one visible in Excel. Please check the attached project and screenshot!
Thank you
Dragos Culea
RefId: 39953
Hi,
Thanks for the sample project.
I can notice the issue using your template Excel file and code, it does not give correct width in Inches.
Sample code:
var excelWorkbook = new Workbook(@“e:\test2\ColumnWidth.xlsx”);
var cells = excelWorkbook.Worksheets[0].Cells;
var inches = cells.GetColumnWidthInch(0);//actual value is 1.1458333333333333, expected 1.21
Sample code:
var excelWorkbook = new Workbook(@“e:\test2\ColumnWidth.xlsx”);
var cells = excelWorkbook.Worksheets[0].Cells;
var inches = cells.GetColumnWidthInch(0);//actual value is 1.1458333333333333, expected 1.21
I have logged a ticket with an id: CELLSNET-41122 for your issue. We will soon look into it.
Thank you.
Hi,
Thanks for using Aspose.Cells.
If the view type of the sheet is changed in MS Excel, the displayed column width will be change too.
Pease try Cells.GetViewColumnWidthPixel method with the following code:
C#
Aspose.Cells.Workbook excelWorkbook = new Aspose.Cells.Workbook(@“D:\Filetemp\ColumnWidth.xlsx”);
var cells = excelWorkbook.Worksheets[0].Cells;
excelWorkbook.Worksheets[0].ViewType = ViewType.NormalView;
Console.WriteLine( cells.GetViewColumnWidthPixel(0));
excelWorkbook.Worksheets[0].ViewType = ViewType.PageLayoutView;
Console.WriteLine(cells.GetViewColumnWidthPixel(0));
MS Excel only stores the data about the column width in the normal view.
There is no actual column width of PageLayout view in the file, MS Excel expands the normal column width with different scale according to default font setting.
We could not get the same width as MS Excel because the scale is transparent, so the method Cells.GetViewColumnWidthPixel is not accurate.