Free Support Forum - aspose.com

Getting correct column width

I downloaded a trial version of ASPOSE to test its use for a client's product.

The product's goal is to read an XLS file created in Excel and reformat it using ASPOSE.

I ran a test case with the attached file. It has two columns, col A has default size and col B is extra wide.

However when I read column widths using the Cells.GetColumnWidth(col index) or Cells.GetColumnWidthPixel(col index), I get the same value for both columns. I expected column B to be larger. How do I get the correct column width?

Thanks,

Andrew

PS. Here is the output from a debug session displaying widths of the two columns.

book.Worksheets[0].Cells.GetColumnWidthPixel(0)

64

book.Worksheets[0].Cells.GetColumnWidthPixel(1)

64

Hi,

Which version you are using, kindly try the attached version. I tested your template file using your code with the attached version and it works fine to give 64 and 141 values respectively for the two columns i.e., A and B.

Thank you.

I still get the same values using the attached dll.

Can you include the code you are using to read the column size?

Thanks

Andrew

Hi Andrew,

Now that looks very strange as I get perfect results. I think you are not using the above version (4.5.0.11) and still using some older version. Please make sure that you are using the above version (4.5.0.11).

Here is my testing code:

Workbook book = new Workbook();

book.Open("d:\\test\\Book1WideBCol.xls");

MessageBox.Show(book.Worksheets[0].Cells.GetColumnWidthPixel(0).ToString());

MessageBox.Show(book.Worksheets[0].Cells.GetColumnWidth(0).ToString());

MessageBox.Show(book.Worksheets[0].Cells.GetColumnWidthPixel(1).ToString());

MessageBox.Show(book.Worksheets[0].Cells.GetColumnWidth(1).ToString());

If you still find the problem, could you create a simple and fresh console application to show the issue, zip it and post it here, we will check it soon.

Thank you.