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

Free Support Forum - aspose.com

Autofit column after setting the date format in Excel using Aspose.Cells for .NET in C#


In my excel, i selected a cell and that cell i set a format like date,“Wednesday, March 14, 2012”, in Format Cells.

In my code:


where datetimeValue is System.Datetime.

The value of cell.StringValue is not the format that i set in the excel but is the same date of datetimeValue . And the autoFitColumn function calculated the width seems using cell.StringValue.
As a result when i open the excel, the value is correct but the width is too narrow to shown the whole format and become ######.
My Question is how could i handle it?


Thanks for the details.

I tested your scenario/ case a bit using the following sample code,it works fine and as expected. Please see the sample code and find attached the output Excel file for your reference:
Sample code:

Workbook wb = new Workbook();
            Worksheet ws = wb.Worksheets[0];
            DateTime dt = DateTime.Now.Date;

            Style style = wb.CreateStyle();
            style.Custom = "[$-F800]dddd, mmmm dd, yyyy";




If you still find any issue, kindly do provide your sample code (runnable) and template file to show the issue, we will check it soon.
files1.zip (6.4 KB)

Thank you for your reply. I fixed it because i used an old version


Good to know that your issue is sorted out by newer versions. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.