jferard / fastods

A very fast and lightweight (no dependency) library for creating ODS (Open Document Spreadsheet, mainly for Calc) files in Java. It's a Martin Schulz's SimpleODS fork
GNU General Public License v3.0
36 stars 6 forks source link

Data Pilot Tables #155

Closed jferard closed 5 years ago

jferard commented 5 years ago

It would be nice to have Data Pilot Tables, but there is an issue: LO creates the OpenDocument data pilot table (and FastODS could create such a table) but LO update the regular table too. That means you have a regular table:

<table:table>
    -> content of the data pilot here (values are computed)
</table:table>
<table:data-pilot-tables>
      <table:data-pilot-table>
            -> description of the data pilot table as in 9.6 here
      </table:data-pilot-table>
</table:data-pilot-tables>

If FastODS provides only the 9.6 description, then the content is empty until it is updated. Trigger an event to update the regular table is possible, but it's a hack. It would be nice to trigger once and then remove the event (or maybe that's a worse hack!).

An example (without regular content):

<table:table table:name="Pivot Table_Sheet1_1" table:style-name="ta1"><table:table-column table:style-name="co1" table:default-cell-style-name="ce43"/><table:table-column table:style-name="co1" table:default-cell-style-name="ce48"/><table:table-column table:style-name="co1" table:default-cell-style-name="ce54"/>
</table:table><table:named-expressions/>
<table:data-pilot-tables>
    <table:data-pilot-table
        table:name="DataPilot1"
        table:application-data=""
        table:target-range-address="&apos;Pivot Table_Sheet1_1&apos;.A1:&apos;Pivot Table_Sheet1_1&apos;.C10"
        table:buttons="&apos;Pivot Table_Sheet1_1&apos;.A2 &apos;Pivot Table_Sheet1_1&apos;.B1"
        table:show-filter-button="false"
        table:drill-down-on-double-click="false"><table:source-cell-range table:cell-range-address="Sheet1.A1:Sheet1.M119"/>
        <table:data-pilot-field table:source-field-name="" table:is-data-layout-field="true" table:orientation="column" table:used-hierarchy="-1" table:function="auto"><table:data-pilot-level table:show-empty="true" calcext:repeat-item-labels="false"/></table:data-pilot-field>
        <table:data-pilot-field table:source-field-name="PERIOD" table:orientation="row" table:used-hierarchy="0" table:function="auto">
            <table:data-pilot-level table:show-empty="false" calcext:repeat-item-labels="false">
                <table:data-pilot-display-info table:enabled="false" table:display-member-mode="from-top" table:member-count="0" table:data-field=""/><table:data-pilot-sort-info table:order="ascending" table:sort-mode="name"/><table:data-pilot-layout-info table:add-empty-lines="false" table:layout-mode="tabular-layout"/></table:data-pilot-level>
        </table:data-pilot-field>
        <table:data-pilot-field table:source-field-name="SYMBOL" table:orientation="data" table:used-hierarchy="0" table:function="count">
            <table:data-pilot-level table:show-empty="false" calcext:repeat-item-labels="false">
                <table:data-pilot-display-info table:enabled="false" table:display-member-mode="from-top" table:member-count="0" table:data-field=""/><table:data-pilot-sort-info table:order="ascending" table:sort-mode="name"/><table:data-pilot-layout-info table:add-empty-lines="false" table:layout-mode="tabular-layout"/></table:data-pilot-level>
        </table:data-pilot-field>
        <table:data-pilot-field table:source-field-name="ATOMIC_WEIGHT" table:orientation="data" table:used-hierarchy="0" table:function="sum">
            <table:data-pilot-level table:show-empty="false" calcext:repeat-item-labels="false">
                <table:data-pilot-display-info table:enabled="false" table:display-member-mode="from-top" table:member-count="0" table:data-field=""/><table:data-pilot-sort-info table:order="ascending" table:sort-mode="name"/><table:data-pilot-layout-info table:add-empty-lines="false" table:layout-mode="tabular-layout"/></table:data-pilot-level>
        </table:data-pilot-field>
    </table:data-pilot-table>
</table:data-pilot-tables>
jferard commented 5 years ago
for each oSheet in thiscomponent.sheets
    for each oPilot in oSheet.DataPilotTables
        oPilot.refresh
    next oPilot
next oSheet
jferard commented 5 years ago

See #130.

There could be an option refreshOnOpen with a self destroying macro:

jferard commented 5 years ago

See #160 & #161: provide a tool to achieve this goal. The performance cost would be left to the user's decision.