Problem exporting date TextObject to Excel
Hi, i need to export my report to excel (xls or xml) but i'm stucked to an annoying problem. I've some TextObject formatted as "Date" (i've tried with "d","dd/MM/yyyy", "MM/dd/yyyy"), but when i generate a report and export it to excel my cells are in "Generic" format. My number textobjects are exported as "Custom" and not number in excel.
Which is the correct way to preserve the right cell format?
Thank you.
Which is the correct way to preserve the right cell format?
Thank you.
This discussion has been closed.
Comments
Hi, are there any news about this topic? I've tried even with the last FastReport version but the problem still persists. A TextObject formatted as Date, in excel, is always formatted as General.
Thank you
I am having the same issue
Fast Report 2015.2 , Excel 2010
I am having the same issue ... any idea pls
Hello!
To preserve native Date formatting in Excel exports (.xlsx / Excel2007Export):
The underlying column in your DataTable or business object must be strictly typed as System.DateTime. If it is System.String, FastReport treats it as text and exports it as a string (t="s"), which Excel displays as General.
Use raw field binding [Orders.OrderDate] instead of [FormatDateTime([Orders.OrderDate], ...)] or string concatenation.
Use TextObject.Format: Right-click the TextObject in the designer -> Format... -> select Date (e.g. dd/MM/yyyy or MM/dd/yyyy). Programmatically:
textObject.Format = new DateFormat { Format = "dd/MM/yyyy" };When configured this way, FastReport writes the serial date number (e.g., 46339) to the cell and embeds a <numFmt formatCode="dd/MM/yyyy;@"/> style in the OpenXML stylesheet. Excel opens it as a true native Date.
The legacy Excel 2003 XML export formats dates as <Data ss:Type="String">. If you require true Excel Date cells, use FastReport.Export.OoXML.Excel2007Export (.xlsx).