pratik227/vue3-json-excel

Problem to open xlsx file

Closed this issue · 7 comments

when I try to open xlsx with my default client (onlyoffice) the file is displayed in a totally strange way as if it were a broken word file:

image

html code:

<download-excel
                      footer="test"
                      type="xlsx"
                      :meta="json_meta"
                      class="mobileShow"
                      :name="excelname"
                      :data="removeIdPedidoId"
                    >
                      <q-icon
                        name="las la-file-excel"
                        size="2em"
                        class="self-center mr-2 cursor-pointer"
                      /><label class="text-sm font-normal cursor-pointer"
                        >{{ $t("Export") }}
                        <label class="font-semibold cursor-pointer"
                          >{{ $t("Page") }} {{ page }}</label
                        >
                        {{ $t("in_excel_format") }} ({{
                          $t("download_excel_obs")
                        }})
                      </label>
                    </download-excel>

script code:

data() {
   return {
     excelname: "",
     json_meta: [
       [
         {
           key: "charset",
           value: "utf-8",
         },
         {
           font: "Arial",
           fontSize: 12,
         },
       ],
     ],
},
methods: {
renameExcelName() {
     this.excelname =
       this.$t("Results_of_analyzes_of") +
       " " +
       this.analise +
       " - " +
       this.initialDate +
       " - " +
       this.finalDate +
       " - " +
       "Página " +
       this.page +
       " - " +
       this.token.name +
       ".xlsx";
   },
},
computed: {
   removeIdPedidoId() {
     return this.Results.filter((item) => {
       // remove o id do pedido e do id do resultado
       //delete item.Enviado;
       item.Enviado = this.getHumanDate(item.enviado);
       delete item.criadoem;
       delete item.atualizadoem;
       delete item.pedidoid;
       delete item.mn_meh;
       delete item.mn_dtpa;
       delete item.id;
       return item;
     });
   },
 },

Hi @lokize,

Sorry mate but I have only tested with ms excel. I'm not sure it will work with onlyoffice or not. Can you try any other editor or CSV ?

Thanks,
Pratik Patel

i tried with Microsoft Office 365 and not worked too

wrong format error

Hi @lokize,

Hi mate I just tried it on local It's working mate.

image
<download-excel
  class="btn btn-default"
  :data="json_data"
  :fields="json_fields"
  type="xlsx" worksheet="My Worksheet"
  name="filename.xlsx"
>
  Download Excel (you can customize this with html code!)
</download-excel>

<script>
import {defineComponent} from 'vue';
import JsonExcel from "vue-json-excel3";

export default defineComponent({
  name: 'IndexPage',
  components:{
    downloadExcel:JsonExcel
  },
  data(){
    return {
      json_fields: {
              "Complete name": "name",
                  City: "city",
                  Telephone: "phone.mobile",
                  "Telephone 2": {
                  field: "phone.landline",
                      callback: (value) => {
                      return `Landline Phone - ${value}`;
                  },
              },
          },
          json_data: [
              {
                  name: "Tony Peña",
                  city: "New York",
                  country: "United States",
                  birthdate: "1978-03-15",
                  phone: {
                      mobile: "1-541-754-3010",
                      landline: "(541) 754-3010",
                  },
              },
              {
                  name: "Thessaloniki",
                  city: "Athens",
                  country: "Greece",
                  birthdate: "1987-11-23",
                  phone: {
                      mobile: "+1 855 275 5071",
                      landline: "(2741) 2621-244",
                  },
              },
          ],
    }
  },
});
</script>


"vue-json-excel3": "^1.0.20",

maybe a problem because my json have many lines and is huge?

example of:

[ { "Número": "10750/2024", "Descrição": "PM NUEVO/ P 01", "Fazenda": "SANTA ANA - Asunción - Distrito Capital", "Proprietário": "NUTRISILO SA", "Enviado": "26/04/2024", "Talhão": "", "pH_Água": "n.s", "pH_CaCl": "5.34", "pH_SMP": null, "pH_KCl": "n.s", "Ca": "3.2", "Mg": "0.79", "Al": "0", "H_Al": "n.s", "K_cmolc": "n.s", "SB": "4.15", "T": "6.96", "v_cmolc": "59.63", "m_cmolc": "0", "Ca_CTC": "0.46", "Mg_CTC": "0.11", "K_CTC": "0.02", "H_Al_CTC": "40.37", "K_mg": "0", "P_res": "n.s", "P_rem": "n.s", "P_meh": "4.87", "P_total": "n.s", "S": "n.s", "B": "n.s", "Cu_Meh": "n.s", "Fe_Meh": "n.s", "Zn_Meh": "n.s", "Cu_DTPA": "n.s", "Fe_DTPA": "n.s", "Zn_DTPA": "n.s", "Na": "n.s", "Argila": "n.s", "Silte": "n.s", "Areia_Fina": "n.s", "Areia_Grossa": "n.s", "Areia_Total": "n.s", "Mat_Org": "n.s", "Carb_Org": "n.s" }, ]

with openoffice work good as expected

image

it's working mate.

but for some strange reason it continues with problems to open, I tried to use a website (https://www.zamzar.com/convert/ods-to-xls/) to convert from ods to xls and after conversion the file worked perfectly, for some reason it seems that the file is being exported to ods

did you managed to get resolved ?