1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
cd "C:\QVApp\Генерация чарта" #Очищаем лог Clear #Открываем файл Excel с выражениями $excelApp = New-Object -ComObject Excel.Application $excelApp.Visible = $true $wb = $excelApp.Workbooks.Open("C:\QVApp\Генерация чарта\Expressions3.xlsx") #Активируем нужный лист $ws = $wb.worksheets | where {$_.name -eq "Лист1"} #<------- Selects sheet 1 # Activate sheet 1 $ws.activate() #Посчитаем количество строк $mainRng = $ws.UsedRange.Cells $RowCount = $mainRng.Rows.Count $RowCount = $RowCount-1 #Открываем приложение QlikView $objApp = new-object -comobject QlikTech.QlikView -strict $objDoc = $objApp.OpenDoc("C:\QVApp\Генерация чарта\Temp3.qvw") #Идентифицируем диаграмму $objChart = $objDoc.GetSheetObject("CH01") #условная видимость #$objProperties.Expressions.Item(0).Item(0).Data.EnableCondition.Expression | gm #Первый цикл - добавим сами выражения $row=1 Do { $row = $row + 1 $exp = $ws.Cells.Item($row,2).value() $objChart.AddExpression($exp) } until ($row -gt $RowCount) #Идентифицируем своства диаграммы с уже созданными выражениями $objProperties = $objChart.GetProperties() #Второй цикл - назовем колонки $row=1 Do { $row = $row + 1 $lbl = $ws.Cells.Item($row,1).value() $def = $ws.Cells.Item($row,3).value() $textcolor = $ws.Cells.Item($row,4).value() $textformat = $ws.Cells.Item($row,5).value() $background = $ws.Cells.Item($row,6).value() $Dec = $ws.Cells.Item($row,7).value() $Fmt = $ws.Cells.Item($row,8).value() $nDec = $ws.Cells.Item($row,9).value() $Thou = $ws.Cells.Item($row,10).value() $Type = $ws.Cells.Item($row,11).value() $UseThou = $ws.Cells.Item($row,12).value() $Comment = $ws.Cells.Item($row,13).value() $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.Label.v = $lbl $objProperties.Expressions.Item($row-1).Item(0).Data.EnableCondition.Type = 2 $objProperties.Expressions.Item($row-1).Item(0).Data.EnableCondition.Expression = $def $objProperties.Expressions.Item($row-1).Item(0).Data.AttributeExpressions.TextColorExp.Definition.v = $textcolor $objProperties.Expressions.Item($row-1).Item(0).Data.AttributeExpressions.TextFmtExp.Definition.v = $textformat $objProperties.Expressions.Item($row-1).Item(0).Data.AttributeExpressions.BkgColorExp.Definition.v = $background $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.NumberPresentation.Dec = $Dec $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.NumberPresentation.Fmt = $Fmt $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.NumberPresentation.nDec = $nDec $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.NumberPresentation.Thou = $Thou $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.NumberPresentation.Type = $Type $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionVisual.NumberPresentation.UseThou = $UseThou $objProperties.Expressions.Item($row-1).Item(0).Data.ExpressionData.Comment = $Comment $objChart.SetProperties($objProperties) } until ($row -gt $RowCount) |
PowerShell и API генерация формул (Expression) в объекте QlikView
