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

Free Support Forum - aspose.com

Unable to map the custom exported datetime format to Excel date time(built in) format

Hi

We are having an issue in formatting datetime data using aspose cell.net.

Exported custom formatted datetime data is not getting mapped to the excel datetime format. when we see the cell format for the exported data in excel sheet, it always maps to custom format of cutom format category instead of mapping to any of the datetime format under date category(Refer the attachment)

Hi,

Please provide us your actual output and expected output files. You can create both of them manually using Ms-Excel for illustration purpose.

Also, if you want to set the datetime format, then please refer to the following document.

Setting Display Formats of Numbers and Dates

Please see the sub-headings:

Using Built-in Number Formats
Using Custom Number Formats

Hi

Please find the attached files.

Let us know the support contact number(toll free) so that we can discuss in detail.

Regards

Sreeni

Hi,

Please set Style.Number = 14.

It will display your date format in this format: m/d/yy

Let me tell you, it is a built-in date format, so dialog box will show you the correct selection when you will view in Ms-Excel.

Please see the code.

C#



Cell yourCell;


Style st=yourCell.GetStyle();

st.Number = 14;

yourCell.SetStyle(st);

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Our requirement is as simple as that we will be applying custom format [Eg: m-d-yyyy h:mm AM/PM] for an excel cell, currently it is displaying under custom category when we select that cell and view in Format Cell property window.

But it should list under Date category, How can we achieve this? As we need to display Date data in Date format in Format Cell property window irrespective of any custom format applied.

Thanks

-Vinaya

Hi

Awaiting speedy support.

Thanks in advance.

/Sreeni

Hi,

Please see the following code.

I have attached the output file for your reference. Kindly see the screenshot attached, as you can see it has been mapped with built-in type.

C#


Workbook workbook = new Workbook();


DateTime dt = DateTime.Now;


Cell a1 = workbook.Worksheets[0].Cells[“A1”];


a1.PutValue(dt);


Style st = a1.GetStyle();

st.CultureCustom = “m/d/yy;@”;

st.Custom = “m/d/yy;@”;

a1.SetStyle(st);



workbook.Save(“output.xlsx”);

Screenshot:

Thank you for the reply. We have a SPECIFIC requirement where date fields need to be exported as "mm/dd/yyyy" with DATE TYPE. Right now Aspose exports the date values with "mm/dd/yyyy" as CUSTOM TYPE.

So please let us know how we can export DATE VALUES with "mm/dd/yyyy" as DATE TYPES and not CUSTOM TYPE

Thanks

Prasad

Hi,

You will have to set the style specifically as I shared. But I have forwarded your question to development team, so that you could get correct information.

Also, I have logged this issue in our database. Once, we will get some update relating to it, we will let you know asap.

This issue has been logged CELLSNET-40475.

Thank you. The style you have suggested is for "m/d/yy" and that is working. But our requirement demands us to format the data as "mm/dd/yyyy" with date type which is different. So please check accordingly.

In brief: how one can export the date data with specific format "mm/dd/yyyy" as excel DATE TYPE and not "Custom type". We have already recieved info on "m/d/yy" but that is not what we are looking for.

Thanks

Prasad

Hi,

Let me know if this one works for you. I have attached the output.xlsx file for your reference.

C#


Workbook workbook = new Workbook();


DateTime dt = DateTime.Now;


Cell a1 = workbook.Worksheets[0].Cells[“A1”];


a1.PutValue(dt);


Style st = a1.GetStyle();

st.CultureCustom = “[$-409]m/d/yy\ h:mm\ AM/PM;@”;

st.Custom = “[$-409]m/d/yy\ h:mm\ AM/PM;@”;

a1.SetStyle(st);



workbook.Save(“output.xlsx”);