While it is difficult to simulate the actual compression of a spring in SolidWorks, you can create multiple configurations to represent the different compression states of a spring. This will allow you to quickly switch back and forth between different lengths of a spring, and with a design table, you can easily create as many configurations as needed. Check out the video below to see how I use a design table to configure a variable pitch spring with different lengths: