Excel trendlines

Hi,
I’ve managed plotting a linear graph with excel, using Ruby code.
The relevant part of the code is attached in the txt file.
Now, in addition to the graph I’ve plotted, I also want to add a linear
trendline on the same chart, show the linear equation and R squared, if
possible.
I couldn’t find anything on google, can anyone help?

Any help would be highly appreciated.
Thanks!