问题
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:
- Open Jenkins
- Select job
- In that job select “Testdata A (Or the unique number 1)
- Also select “Testdata A1” +” Testdata A2” (Or the unique number 1.1 & 1.2)
- Save
- Run Job
- Jenkins takes my selection, opens excel in background and makes the modifications In excel by the selection I made true the UI of Jenkins.
- 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
- 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