java点击表格数据可以写入_E013 如何把Excel表格数据写入Ppt文本框内

2bba7b7baf4d73c512b4e7133e70bb7a.png

40340d2ffab72aeda1f3ec3cd00dc9be.png

Hi,How are you doing?

我是职场编码(CodeVoc)。

在E000中,我们介绍了Node.js、Ruby、Electron等工具下载安装。

这期,给你演示一下由Electron联合Ruby制作的小工具。

知乎视频​www.zhihu.com
zhihu-card-default.svg

借助Electron官方Demo,我们很容易制作一个工具展示平台。

bd836604629c1462c971e499153fa1ee.png

点击“View Demo”会弹出我们的工具界面。

39f0ef27e22c190273f3c3f50973fdc6.png

一、项目需求

这个工具的主要目的是为了把Excel表格数据写入Ppt文本框内。

它除了可以选择源文件,还可以选择目标文件。

点击“写入”按钮,就完成了Excel表格数据写入Ppt文本框操作。

5743dac86e408119535fb86e997e8fe2.png

二、界面设计

【html】

生成表单容器:<form></form>

生成布局标签:<div></div>

生成行内标签:<span></span>

生成单行输入框:<input id="source_line"><input id="goal_line">

生成文件选择按钮:

<input type="file" id="goal_file"> 
<input type="file" id="source_file"> 

生成普通按钮:<input type="button" id="execute">

【css】

关注四点前白后绿气泡某杺平台,搜索“职场编码”查看源码。

【javascript】

根据ID,选中source_file按钮

var source_line=document.getElementById('source_line')

给source_file按钮,添加"change"事件

source_line.value=document.getElementById('source_file').files[0].path 

根据ID,选中goal_file按钮,

var goal_line=document.getElementById('goal_line')

给goal_file按钮,添加"change"事件

goal_file.value=document.getElementById('goal_file').files[0].path 

execute按钮添加单击事件

execute.addEventListener("click",function(){获取参数1,获取参数2,调用})

获取参数1

var source_line=document.getElementById('source_line').value

获取参数2

var goal_line=document.getElementById('goal_line').value

调用Ruby脚本

const { spawn } = require('child_process')
const ls = spawn('ruby', ['Ruby脚本完整路径',参数1,参数2])

三、逻辑梳理

=> 基础语法

引用Ruby标准库

require "win32ole"

创建双参数入口方法

def Excel_to_ppt(pth_source,pth_goal)

接收控制台传双参

Excel_to_ppt(ARGV[0],ARGV[1])

幻灯片计数、创建数组

n=pst.slides.count
arr=Array
arr=ebk.worksheets(1).usedrange.value

设置循环

123.times{
}
(1..n/2).each{|i|
}

=> 对象模型

创建可视化Excel、Ppt应用

@eap=WIN32OLE::new("excel.application");@eap.visible=true
@pap=WIN32OLE::new("powerpoint.application");@pap.visible=true

打开Excel工作簿、Ppt演示文稿

ebk=@eap.workbooks.open(pth_source)
pst=@pap.presentations.open(pth_goal)

操作slides对象

pst.slides(2).copy
pst.slides.paste 3
pst.slides(1).copy
pst.slides.paste 3

执行数组写入Ppt文本框操作(格式化:format("%1d",数据))

pst.slides(j).shapes(1).textframe.textrange.text=format("%1d",arr[i][0])+"."+arr[i][2]
pst.slides(j+1).shapes(1).textframe.textrange.text=arr[i][3]

关注四点前白后绿气泡某杺平台,搜索“职场编码”查看源码。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值