Is there a way to set the width of a column to show all the data within that column like the Autofit works in Excel?? I’m using the ImportDataTable Method to load data into Excel, but I don’t know the width of the data within the columns of the datatable. If there is not an Autofit, how can I find the width of the data in a cell to set the width of the column.
Thanks
Tim Meyer
Pioneer Hi-bred Inc., A DuPont Company
Dear Tim,
Thanks for your consideration.
I plan to offer “AutoFit” feature at the end of this month. Please wait for a few days.
Dear Tim,
Please refer to https://forum.aspose.com/t/119949.
In Hotfix 1.5.11, the AutoFit feature is added. Please download it.
@tmeyer,
We recommend you to try our latest library with new exciting features. You can achieve your desired output using the following sample code:
string InputPath = dataDir + "Book1.xlsx";
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(InputPath, FileMode.Open);
// 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];
// Auto-fitting the 3rd row of the worksheet
worksheet.AutoFitRow(1);
// Saving the modified Excel file
workbook.Save(dataDir + "output.xlsx");
// Closing the file stream to free all resources
fstream.Close();
For more details have a look at the following article:
AutoFit Rows and Columns
Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)
You can download the latest demos here.