This content has been marked as final. Show 11 replies
I think its Excel's issue. If you open Excel and type the number 1560010939089, it would show 1.56001E+12, because by default data type of the Excel Cell is GENERAL. So, if you format the cell and make its data type as Number, the problem would be solved.
In your case, after exporting the data from Apex, change the column format as NUMBER in Excel to display the number in right format.
You can write your own procedure to export to excel. In the following way you can do it and also resolve the issue you are having.
1. Create a report on emp table, showing columns empno, ename and sal.
2. Create a blank page.
3. Create a Before Header process in this blank page with the following code:
i NUMBER := 0;
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="emp.csv"');
-- Close the HTTP Header
-- Loop through all rows in EMP
for x in (select ename, empno, sal
where deptno = :P73_DEPTNO)
i := i + 1;
-- Print out a portion of a row,
-- separated by commas and ended by a CR
if i = 1 then
htp.prn('Name' ||','|| 'Empno' ||','|| 'Salary' || chr(13));
htp.prn(x.ename ||','|| x.empno ||','||
'='||'"'||x.sal||'"' || chr(13));
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
4. Create a button in the report to branch to the above created blank page.
And that's it.
Note that I have used '=' and " in the above procedure to handle the number formatting issue.
Hope it helps.