Forum Discussion

LennSar's avatar
LennSar
Contributor
3 years ago

delete or clear excel xlsx file

Hi there,

I use a xlsx file to basically buffer some reference data. In the first step I generate that data, write it to a xlsx file and later get that data back from the xlsx file to compare it against the response of a Rest get request. 
To make sure that I only have the data generated in the current run I delete the files in an initial step using this groovy script:

def prjPath = context.expand('${projectDir}')
new File("${prjPath}/reports.xlsx").delete()
new File("${prjPath}/reportDates.csv").delete()

I can see from a command line and the explorer that the file is deleted but once I access it at the end of the above described process again the file contains the old data and the new data is appended to the data from the previous ran.

I assume this is some funny Windows magic which is caused by Windows not really deleting the file and by generating it with the 'Append' check box activated I basically retrieve the file from the trash and append the new data to it? 

Therefore, I would like to ask you whether you know of any good way to either REALLY delete these files or clear the content of the files.

 

Thanks a lot!

 

  • I can't delete it but if you happen to be in the wrong forum again, ask and we can move it for you. 😉

  • Just realised this is the wrong forum as this is ReadyApi related. May some overpowered individual please delete this? I copied this to the ReadyApi Community

    • Marsha_R's avatar
      Marsha_R
      Moderator

      I can't delete it but if you happen to be in the wrong forum again, ask and we can move it for you. 😉