第1个回答 2023-01-20
dim a, text
Call Plugin.Office.OpenXls("C:\AA.xls")
a = 1
x = 1
y = 2
for i = 1 to 10
text = Plugin.Office.ReadXls(1, a, 1)
a = a + 1
Call Plugin.Office.WriteXls(2, x, 1, text)
x = x + 1
Call Plugin.Office.WriteXls(2, y, 1, text)
y = y + 1
next
上面代码中,使用for循环读取A列的第1~10行数据,并依次写入B列和C列的对应位置。
如果需要读取多列,可以在for循环中嵌套循环,再调用ReadXls和WriteXls函数即可。
如果需要读取A列10条数据输出,在依次读取另外10条输出,可以在外层循环中加一个循环变量来实现,假设每次读取10条数据,总共读取100条数据,可以这样写:
dim a, text
Call Plugin.Office.OpenXls("C:\AA.xls")
a = 1
x = 1
y = 2
for i = 1 to 10
for j = 1 to 10
text = Plugin.Office.ReadXls(1, a, 1)
a = a + 1
Call Plugin.Office.WriteXls(2, x, 1, text)
x = x + 1
Call Plugin.Office.WriteXls(2, y, 1, text)
y = y + 1
next
next
上面代码中,外层循环i控制每次读取10条数据,内层循环j控制读取A列第1~10行数据,实现读取A
第2个回答 2022-12-15
您可以使用按键精灵中的循环语句来实现这个功能。代码类似如下:
// 设置每次读取的数据条数
const int per_count = 10;
// 读取总条数
const int total_count = 100;
// 循环次数
const int loop_count = total_count / per_count;
// 循环读取数据
for (int i = 0; i < loop_count; ++i) {
// 读取A列的第i*per_count+1到(i+1)*per_count条数据
// 例如第一次读取A列的第1到10条数据,第二次读取第11到20条数据
// 读取方法可以使用按键精灵提供的EXCEL读取函数
// 输出方法可以使用按键精灵提供的输出函数
}
希望这些信息能够帮助您解决问题。
追问放在按键精灵中不能用
第3个回答 2022-12-14
按键精灵里的插件命令:
//定义变量//
dim a,text
Call Plugin.Office.OpenXls(C:\AA.xls)
a = 1
x = 1
y = 2
//读取表格,括号内第2个是行,第3个是列//
Text = Plugin.Office.ReadXls(1, a, 1)
a = a + 1
//写入指定位置//
Call Plugin.Office.WriteXls(2, x, 1, text)
x = x + 1
Call Plugin.Office.WriteXls(2, y, 1, text)
y = y + 1
如果需要读取B列,C列,就定义多几个变量,最后写个循环命令就行了。
本回答被网友采纳
第4个回答 2023-01-20
//设置变量i,jvar i,j;//循环读取A列10行数据for(i=1;i<=10;i++){ //获取第i行A列的值 j=Excel_ReadCell("A"+i); //输出第i行A列的值 Dialog_ShowMessage(j);}