Changing Excel spreadsheet cells through the usage of Jenkins

白昼怎懂夜的黑 提交于 2019-12-08 10:30:17

问题


I want to make an adjustment to a cell in excel without opening the application for it. I want to do this with Jenkins so i can automate (regression)tests. (Is this even possible??)

As you can see in the image I attached, I wat to change a “N” value in excel to an “Y” value, or vice versa. I want to achieve this trough the UI of Jenkins. I’ve heard something like a parametrized build, but I can’t get my hands on any website or something that can tell me more about this subject.

What I want to achieve is something like this:

  1. Open Jenkins
  2. Select job
  3. In that job select “Testdata A (Or the unique number 1)
  4. Also select “Testdata A1” +” Testdata A2” (Or the unique number 1.1 & 1.2)
  5. Save
  6. Run Job
  7. Jenkins takes my selection, opens excel in background and makes the modifications In excel by the selection I made true the UI of Jenkins.
  8. In other words: by selecting “Testdata A” in Jenkins and running the job, the “N” in cel C2 needs to change to a “Y”. Also for other selections like the ones in cel C3 & C4
  9. I want to do this for more then 1x. The idea is to use excel where all cell's already have a "N" and only changes to an "Y" when i select this true Jenkins.

My apologies for my bad English. I hope I have clearly described what I want. Please add a comment if you require more explanation. Thanks in advance

Excel Testdata


回答1:


You might find it simpler to have Jenkins execute a vbscript that accesses and updates your file as required. You can pass the relevant parameters to a script that will then do something along the lines of:

Dim xlApp : Set xlApp = CreateObject("Excel.Application")
Dim wkBk : Set wkBk = xlApp.Workbooks.Open("pathToWorkBookHere")
Dim wSheet : Set wSheet = wkBk.WorkSheets("yourSheetNameHere")

With wSheet.Range("C3")
    .Value = Wscript.Arguments(0) ' This could be a Y or an N, whatever you passed into the script
End With

You could easily scale that up over multiple workbooks/worksheets/cells as required.



来源:https://stackoverflow.com/questions/37326446/changing-excel-spreadsheet-cells-through-the-usage-of-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!