We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SetColumnWidth set only approximate?

I have latest release running.

Should Cells.SetColumnWidth() set the width of the column to
exactly what is specified?

I would like to set it to an exact value, but never can. Notes I
made on what I try and what results are:

'5.2->5.11, 5.3-> 5.22, 5.4-5.5 results in 5.33, 5.6 jumps to 5.56

What units are these?
For that matter, is there a place where you describe what all the
various units are for all the various settings? Nothing in API.

Hi Britt,

That’s caused by MS Excel. You can try it by manually setting column width in MS Excel. One unit of column width is equal to the width of one character in the Normal style. So it’s not an accurate unit.

@britt,
Aspose.Excel is no more continued now and deprecated. A new product Aspose.Cells has replaced this older product and offers all the features provided by different versions of MS Excel. You can set the column width using this new product as follows:

// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);

// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

// Setting the width of the second column to 17.5
worksheet.Cells.SetColumnWidth(1, 17.5);

// Saving the modified Excel file
workbook.Save(dataDir + "output.out.xls");

// Closing the file stream to free all resources
fstream.Close();

Adjusting row height and column width is explained here:
Adjusting Row Height and Column Width

Download the latest version here:
Aspose.Cells for .NET (Latest Version)

Here is a solution which can be used to test a variety of features(https://github.com/aspose-cells/Aspose.Cells-for-.NET).