Property “visible“ must be accessed with “$data.visible“ because properties解决方式

[Vue warn]: data functions should return an object

出现的原因是 结构未定义导致的 例如   const { roles } = await store.dispatch('user/getInfo') 我的那个返回没有 roles 属性。解决方式const { roles = ['admin']  } = await store.dispatch('user/getInfo') 好好检查一下,我调试了好几个小时..

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
function copy-data([int]$startrow, [int]$startcol, [int]$endrow, [int]$endcol, [string]$pat, [string]$file, [int]$sheetfrom, [int]$sheetto) { $excel = New-Object -ComObject Excel.Application $excel.Visible = $false $wb = $excel.Workbooks.Open($file) $wsfrom = $wb.Sheets.Item($sheetfrom) $wsto = $wb.Sheets.Item($sheetto) $sr = $wsfrom.Range($wsfrom.Cells.Item($startrow, $startcol), $wsfrom.Cells.Item($endrow, $endcol)) $fc = $sr.Find($pat) if ($fc -ne $null) { $rown = $fc.Row $dsr = $wsto.Range($wsto.Cells.Item($rown, $startcol), $wsto.Cells.Item($rown + ($endrow - $startrow), $endcol)) $dsr = $dsr.Resize($sr.Rows.Count, $sr.Columns.Count) $sr.Copy() $dsr.PasteSpecial(-4104) } $excel.DisplayAlerts = $false $wb.Close($true) [Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null } $path = $PWD.Path $file = "$path\a.xlsx" # 将sheet1中第1行到第4行、第2列到第9列的数据复制到sheet2中 copy-data -startrow 1 -startcol 2 -endrow 4 -endcol 9 -pat 1009 -file $file -sheetfrom 1 -sheetto 2 # 将sheet1中第6行到第8行、第2列到第9列的数据复制到sheet2中 copy-data -startrow 6 -startcol 2 -endrow 8 -endcol 9 -pat 1018 -file $file -sheetfrom 1 -sheetto 2 # 将sheet1中第10行到第11行、第2列到第9列的数据复制到sheet2中 copy-data -startrow 10 -startcol 2 -endrow 11 -endcol 9 -pat 1023 -file $file -sheetfrom 1 -sheetto 2 这个是搜索sheet1中关键词吗,我现在要搜索sheet2中关键词 得到行信息后再把sheet1指定内容复制到sheet2指定区域,怎么修改呢
05-19
可以按照以下步骤修改代码: 1. 将函数名 `copy-data` 修改为 `copy-data-to-sheet2`,以表明该函数是将数据从 sheet1 复制到 sheet2。 2. 在函数中添加一个新的参数 `$sheetfromname`,用于指定要搜索的 sheet 名称。 3. 修改 `$wsfrom` 的赋值语句,使用 `$wb.Sheets.Item($sheetfromname)` 获取指定的 sheet 对象。 4. 修改 `$wsto` 的赋值语句,使用 `$wb.Sheets.Item(2)` 获取 sheet2 对象。 5. 修改 `$dsr` 的赋值语句,使用 `$wsto.Cells.Item($rown, $startcol)` 获取指定单元格的对象。 6. 将 `$dsr.Resize($sr.Rows.Count, $sr.Columns.Count)` 修改为 `$dsr.Resize($endrow-$startrow+1, $endcol-$startcol+1)`,以根据复制范围计算新区域的大小。 7. 在调用函数时,将参数 `-sheetfrom` 修改为 `-sheetfromname`,并指定要搜索的 sheet 名称。 修改后的代码如下: ``` function copy-data-to-sheet2([int]$startrow, [int]$startcol, [int]$endrow, [int]$endcol, [string]$pat, [string]$file, [string]$sheetfromname, [int]$sheetto) { $excel = New-Object -ComObject Excel.Application $excel.Visible = $false $wb = $excel.Workbooks.Open($file) $wsfrom = $wb.Sheets.Item($sheetfromname) $wsto = $wb.Sheets.Item(2) $sr = $wsfrom.Range($wsfrom.Cells.Item($startrow, $startcol), $wsfrom.Cells.Item($endrow, $endcol)) $fc = $sr.Find($pat) if ($fc -ne $null) { $rown = $fc.Row $dsr = $wsto.Cells.Item($rown, $startcol) $dsr = $dsr.Resize($endrow-$startrow+1, $endcol-$startcol+1) $sr.Copy() $dsr.PasteSpecial(-4104) } $excel.DisplayAlerts = $false $wb.Close($true) [Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null } $path = $PWD.Path $file = "$path\a.xlsx" # 将sheet1中包含关键词 1009 的行复制到sheet2中指定区域 copy-data-to-sheet2 -startrow 1 -startcol 2 -endrow 4 -endcol 9 -pat 1009 -file $file -sheetfromname "sheet1" -sheetto 2 # 将sheet1中包含关键词 1018 的行复制到sheet2中指定区域 copy-data-to-sheet2 -startrow 6 -startcol 2 -endrow 8 -endcol 9 -pat 1018 -file $file -sheetfromname "sheet1" -sheetto 2 # 将sheet1中包含关键词 1023 的行复制到sheet2中指定区域 copy-data-to-sheet2 -startrow 10 -startcol 2 -endrow 11 -endcol 9 -pat 1023 -file $file -sheetfromname "sheet1" -sheetto 2 ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值