Ant读取XML文件的值

     今天因为自动化编译里需要读取xml文件的值,所以记录一下,首先得有一个xml文件如下:

  

<root>
    <project>
      <path>Project-extra</path>
    </project>
</root>

      然后看下build是如何使用的:

<xmlproperty file="ProjectDir/project-config.xml"/>
    
    <!-- 从xml文件读取出来的值 -->
    <property
        name="project-dir"
        value="${root.project.path}" />
      可以看到,在build中使用xml文件配置的值的用法就是先使用xmlproperty去加载指定文件,然后在property中指定value的值为${xml节点}即可。这样我们在build文件中就可以通过project-dir去使用project-config.xml中的值了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ant Design Vue 提供了一个上传组件 `Upload`,通过这个组件可以上传文件到服务器,然后在服务器端读取 Excel 文件里的。 以下是一个简单的示例: ```vue <template> <div> <a-upload :before-upload="beforeUpload" :on-success="onSuccess" :show-upload-list="false" > <a-button> <a-icon type="upload"></a-icon> 点击上传 </a-button> </a-upload> <div v-if="excelData"> <table> <thead> <tr> <th v-for="header in excelData.headers" :key="header">{{ header }}</th> </tr> </thead> <tbody> <tr v-for="(row, index) in excelData.rows" :key="index"> <td v-for="(cell, cellIndex) in row" :key="cellIndex">{{ cell }}</td> </tr> </tbody> </table> </div> </div> </template> <script> import XLSX from 'xlsx'; export default { data() { return { excelData: null, }; }, methods: { beforeUpload(file) { const isExcel = /xlsx|xls/.test(file.type); if (!isExcel) { this.$message.error('只能上传 Excel 文件!'); } return isExcel; }, onSuccess(response) { const reader = new FileReader(); reader.onload = (event) => { const data = event.target.result; const workbook = XLSX.read(data, { type: 'binary' }); const sheetName = workbook.SheetNames[0]; const worksheet = workbook.Sheets[sheetName]; const excelData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); this.excelData = { headers: excelData[0], rows: excelData.slice(1) }; }; reader.readAsBinaryString(response.file); }, }, }; </script> ``` 在这个例子中,我们使用 `XLSX` 库来解析 Excel 文件。在上传成功后,我们使用 `FileReader` 对象来读取上传的文件,并将其转换为二进制字符串, 然后使用 `XLSX` 库将其转换为 JSON 数据。最后,我们将这些数据存储在 `excelData` 变量中,以供渲染。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值