Forum Stats

  • 3,827,928 Users
  • 2,260,839 Discussions
  • 7,897,408 Comments

Discussions

Export to excel exports 0 without saving file

3306268
3306268 Member Posts: 7
edited Oct 10, 2017 1:47PM in JDeveloper and ADF

Hi,

I have "af:exportCollectionActionListener" to export data of af:table to excel. Table has columns (Number field) which when entered  e.g. '300100002555003' it exports  "3.001E+14" to excel.  To fix this issue we added higlighted outputtext above and below the inputtext.

<af:outputText value='=" ' inlineStyle="display:none" id="ot13"/>

<af:inputText .../>

<af:outputText value='"' inlineStyle="display:none" id="ot22"/>

Now the issue is, when we click on export to excel button ,

(1) If we save and then open exported excel file everything is fine

(2) If we directly open file without saving , column gets exported with ''0' value.

Jdeveloper version - 11.1.1.7

Do we really need to every time save exported file before opening?

Thanks

Tagged:

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,462 Red Diamond
    edited Oct 10, 2017 11:21AM

    Well, you can use Apache POI - the Java API for Microsoft Documents which allows you to write native excel files. Using POI you have full control which data is exported in which format.

    Timo

  • 3306268
    3306268 Member Posts: 7
    edited Oct 10, 2017 11:24AM

    Actually export works fine when We save. Only when we try to open file without save it gets exported as '0'. Is this issue with "af:exportCollectionActionListener" component?

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,462 Red Diamond
    edited Oct 10, 2017 1:47PM

    What you can try if you want to stay with the simple exportCollectionActionListener it to add formatting to the data

    <af:column headertext="Some wide label">  <af:panelgrouplayout layout="horizontal">    <af:outputtext value="=TEXT(" inlineStyle="display:none">    <af:outputtext value="#{row.bigNumberValue}" rendered="true"/>     <af:outputtext value=",0)" inlineStyle="display:none">  </af:panelgrouplayout></af:column>

    The trick is to use the inlineStyle and not the visible property. Invisible columns are not exported by the exportCollectionActionListner.

    You have to find out which data results in the output of '0' and decorate it somehow with this trick.

    Timo

This discussion has been closed.