0

I'm a new to code vue page. I want to use vue-office-excel component in my Vue page, it can show an excel file on my page. My vue script is like this.

index.vue:

<template>
    <vue-office-excel :src="'http://static.shanhuxueyuan.com/test.xlsx'" :options="options" @rendered="rendered" @error="error"
           style="height: 100vh;" />
</template>

<script setup>
    import { VueOfficeExcel } from '@vue-office/excel'
    import '@vue-office/excel/lib/index.css'

    const options = ref({
      xls: true,       
      minColLength: 0,  
      minRowLength: 0,  
      widthOffset: 10,  
      heightOffset: 10, 
      beforeTransformData: (workbookData) => {return workbookData}, 
      transformData: (workbookData) => {return workbookData}
    });

    const rendered = () => {
        console.log('Excel rendered')
    }
  
    const error = (error) => {
        console.error('Error loading Excel', error)
    }
</script>

I have set the configurations in package.json as:

{
    ...
    "dependencies": {
        ...,
        "@js-preview/excel": "^1.7.3",
        "@vue-office/excel": "^1.7.3",
        "vue-demi": "^0.14.6",
        "vue": "3.4.31",
        ...
    },
    ...
}

Now it doesn't work, the page shows nothing, and anything is not printed on the console. I'm using Chrome browser ver 136.0.7103.93. I've tried the example, that works correctly.

4
  • src="'http://static.shanhuxueyuan.com/test.xlsx'" - Are you sure you want those single quotes in there? Commented May 13 at 7:06
  • @DarkBee Yes, that's v property, but it doesn't work whether I use :src, src or variable. Commented May 13 at 7:57
  • What I meant was, did you try to remove the single quotes - src="http://static.shanhuxueyuan.com/test.xlsx"? Commented May 13 at 7:59
  • 1
    @DarkBee Tried. Thank you for your help, now I know this component doesn't support vue3, now I've import this vue page as a vue2 component and now it can show the excel I want. Commented May 13 at 8:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.