Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only create the Excel data on button click? #6

Open
jdl2206 opened this issue Jul 14, 2020 · 1 comment
Open

Only create the Excel data on button click? #6

jdl2206 opened this issue Jul 14, 2020 · 1 comment

Comments

@jdl2206
Copy link

jdl2206 commented Jul 14, 2020

Thanks so much for this awesome component! Our data is in a 2D String array so I need to format it as json before the Excel file is created. I'd prefer to only have to format the data when the Download Excel button is clicked. Is there a way to do that?

@antiv
Copy link

antiv commented Nov 12, 2022

Hi,

this is workaround, but you can use ref and call exportExcel().

    <vue-excel-xlsx
            ref="xlsxData"
            style="display: none"
            :data="jsonData['data']"
            :columns="jsonData['columns']"
            file-name="Exported data"
            :file-type="'xlsx'"
            :sheet-name="'Export'"
          >
    </vue-excel-xlsx>
    <button
            type="button"
            class="btn btn-success bi bi-download"
            @click="clickOk"
          >
            Download
     </button>

and in script part:

async clickOk() {
   this.jsonData = await getData();
   setTimeout(() => {
        this.$refs["xlsxData"].exportExcel();
      }, 200);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants