Free Support Forum - aspose.com

PutValue does not automatically format a DateTime

I’m using Aspose.Cells file version 7.3.1.0. The PutValue function, given a DateTime parameter, does not automatically format the cell as a Date, in Excel. It formats it as something else, and in Excel is shows up as an integer value. I have to explicitly use the custom style formatting feature to get it to format as a Date in Excel.


Is there a simpler way to put a date-formatted DateTime object into Excel without having to also always set custom styles?

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We are afraid, you will have to explicitly set the date & time values by formatting them using Style object.

Date & Time values are stored as numbers in Excel, therefore it is important to format them using Style object so that these could be shown correctly.

Well I understand that part, but I was wondering if you all had thought about maybe making the PutValue function automatically apply that formatting when you pass in a DateTime? It’s pretty obvious that we don’t want to render the date as a number … so it’d make sense to automatically format it, right?

Hi,

Thanks for your further feedback.

We have logged your requirements in our database. We will look into this issue and if possible improve it.

Once, we will have some fix or update for you, we will share it with you asap.

This issue has been logged as CELLSNET-41408.

Hi,

Thanks for using Aspose.Cells.

Please try Cell.PutValue(string stringValue, bool isConverted,
bool setStyle)
method.

mshakeel.faiz:
Hi,

Thanks for using Aspose.Cells.

Please try Cell.PutValue(string stringValue, bool isConverted, bool setStyle) method.

I've tried that function. It doesn't seem to do anything different. My dates still appear in Excel as integers.

Hi,

Thanks for your posting and using Aspose.Cells.

It is hard for us to determine whether you want to show the DateTime
value as date or time or both data and time, that is, we cannot know
what the exact formatting you expected for the cell.

For using
Cell.PutValue(string stringValue, bool isConverted, bool setStyle), user
should format the DateTime value as what he wants to get to be shown in
excel firstly, then use this method with isConverted=true and
setStyle=true so we can parse the input stringValue and apply the
formatting to cell automatically.